From: <Mikko.Rapeli@bmw.de>
To: <mike.looijmans@topic.nl>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] sanity.bbclass: check SSTATE_DIR, DL_DIR and *MIRROR for broken symlinks
Date: Mon, 10 Aug 2015 11:48:00 +0000 [thread overview]
Message-ID: <20150810114757.GG6102@loska> (raw)
In-Reply-To: <55C86AA2.2050706@topic.nl>
Hi,
On Mon, Aug 10, 2015 at 11:10:58AM +0200, Mike Looijmans wrote:
> On 10-08-15 10:18, Mikko.Rapeli@bmw.de wrote:
> >On Fri, Jul 31, 2015 at 12:00:15PM +0300, Mikko Rapeli wrote:
> ...
> >>+# Check that path isn't a broken symlink
> >>+def check_symlink(lnk):
> >>+ if os.path.islink(lnk) and not os.path.exists(lnk):
> >>+ return False
> >>+ return True
>
> - Bad coding style "if (x) return false".
> - Naming a method "check..." suggests to me that it will raise an exception
> on failure.
Thanks. I tried to follow existing patterns from the functions there.
> alternatives:
>
> def is_broken_symlink(lnk):
> return os.path.islink(lnk) and not os.path.exists(lnk)
>
> def check_symlink(lnk, data):
> if os.path.islink(lnk) and not os.path.exists(lnk):
> raise_sanity_error("%s is a broken symlink." % lnk, data)
This feels better and reduces the log statements too. Hopefully the generic
error message is enough to figure out what is wrong. I'll test and send a
new version.
Regarding testing, I guess selftests are not generally used to test error
paths like this.
-Mikko
next prev parent reply other threads:[~2015-08-10 11:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 9:00 [PATCH] sanity.bbclass: check SSTATE_DIR, DL_DIR and *MIRROR for broken symlinks Mikko Rapeli
2015-08-10 8:18 ` Mikko.Rapeli
2015-08-10 9:10 ` Mike Looijmans
2015-08-10 11:48 ` Mikko.Rapeli [this message]
2015-08-10 14:00 ` [PATCH v2] " Mikko Rapeli
2015-08-10 16:35 ` [PATCH] " Burton, Ross
2015-08-10 17:02 ` Mikko.Rapeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150810114757.GG6102@loska \
--to=mikko.rapeli@bmw.de \
--cc=mike.looijmans@topic.nl \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox