public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 5/7] oeqa/selftest: improve failure messages for devtool tests
Date: Tue, 23 Dec 2014 16:08:46 +0000	[thread overview]
Message-ID: <2812202181243d7d4ebcbf9c3d5ccf2200816f4b.1419350817.git.paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <cover.1419350817.git.paul.eggleton@linux.intel.com>
In-Reply-To: <cover.1419350817.git.paul.eggleton@linux.intel.com>

assertTrue prints "False is not True" if it fails, which is pretty much
useless. Use a more appropriate assertion test where practical and add a
message where it isn't.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/lib/oeqa/selftest/devtool.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index e8ff536..e158ad9 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -25,15 +25,15 @@ class DevtoolTests(oeSelfTest):
         result = runCmd('devtool create-workspace %s' % tempdir)
         self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf')))
         result = runCmd('bitbake-layers show-layers')
-        self.assertTrue(tempdir in result.output)
+        self.assertIn(tempdir, result.output)
         # Try creating a workspace layer with the default path
         self.track_for_cleanup(workspacedir)
         self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
         result = runCmd('devtool create-workspace')
         self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf')))
         result = runCmd('bitbake-layers show-layers')
-        self.assertTrue(tempdir not in result.output)
-        self.assertTrue(workspacedir in result.output)
+        self.assertNotIn(tempdir, result.output)
+        self.assertIn(workspacedir, result.output)
 
     def test_recipetool_create(self):
         # Try adding a recipe
@@ -74,7 +74,7 @@ class DevtoolTests(oeSelfTest):
         recipefile = os.path.join(tempdir, 'libmatchbox.bb')
         srcuri = 'git://git.yoctoproject.org/libmatchbox'
         result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc))
-        self.assertTrue(os.path.isfile(recipefile))
+        self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output)
         checkvars = {}
         checkvars['LICENSE'] = 'LGPLv2.1'
         checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34'
@@ -111,7 +111,7 @@ class DevtoolTests(oeSelfTest):
         result = runCmd('wget %s' % url, cwd=tempdir)
         result = runCmd('tar xfv pv-1.5.3.tar.bz2', cwd=tempdir)
         srcdir = os.path.join(tempdir, 'pv-1.5.3')
-        self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')))
+        self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory')
         # Test devtool add
         self.track_for_cleanup(workspacedir)
         self.add_command_to_tearDown('bitbake -c cleansstate pv')
@@ -127,9 +127,9 @@ class DevtoolTests(oeSelfTest):
         # Test devtool build
         result = runCmd('devtool build pv')
         installdir = get_bb_var('D', 'pv')
-        self.assertTrue(installdir)
+        self.assertTrue(installdir, 'Could not query installdir variable')
         bindir = get_bb_var('bindir', 'pv')
-        self.assertTrue(bindir)
+        self.assertTrue(bindir, 'Could not query bindir variable')
         if bindir[0] == '/':
             bindir = bindir[1:]
         self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D')
@@ -167,9 +167,9 @@ class DevtoolTests(oeSelfTest):
         result = runCmd("sed -i 's!^\.TH.*!.TH MDADM 8 \"\" v9.999-custom!' %s" % os.path.join(tempdir, 'mdadm.8.in'))
         bitbake('mdadm -c package')
         pkgd = get_bb_var('PKGD', 'mdadm')
-        self.assertTrue(pkgd)
+        self.assertTrue(pkgd, 'Could not query PKGD variable')
         mandir = get_bb_var('mandir', 'mdadm')
-        self.assertTrue(mandir)
+        self.assertTrue(mandir, 'Could not query mandir variable')
         if mandir[0] == '/':
             mandir = mandir[1:]
         with open(os.path.join(pkgd, mandir, 'man8', 'mdadm.8'), 'r') as f:
@@ -223,7 +223,7 @@ class DevtoolTests(oeSelfTest):
             elif re.search('minicom_[^_]*.bb$', line):
                 self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
             else:
-                self.assertTrue(False, 'Unexpected modified file in status: %s' % line)
+                raise AssertionError('Unexpected modified file in status: %s' % line)
 
     def test_devtool_extract(self):
         # Check preconditions
-- 
1.9.3



  parent reply	other threads:[~2014-12-23 16:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
2014-12-23 16:08 ` [PATCH 1/7] oeqa/utils: replace some tabs with spaces Paul Eggleton
2014-12-23 16:08 ` [PATCH 2/7] oeqa/utils: fix testcase decorator to allow calling tests individually Paul Eggleton
2014-12-23 16:08 ` [PATCH 3/7] oeqa/selftest: fix test_event_handler for changes in bitbake output Paul Eggleton
2014-12-23 16:08 ` [PATCH 4/7] oeqa/selftest: skip test_incremental_image_generation if not using rpm Paul Eggleton
2014-12-23 16:08 ` Paul Eggleton [this message]
2014-12-23 16:08 ` [PATCH 6/7] oeqa/selftest: populate pkgdata/shlibs in test_recipetool_create_git Paul Eggleton
2014-12-23 16:08 ` [PATCH 7/7] oeqa/selftest: fix test_force_task so it doesn't taint the entire build Paul Eggleton
2014-12-23 16:20   ` Paul Eggleton

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=2812202181243d7d4ebcbf9c3d5ccf2200816f4b.1419350817.git.paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --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