summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Gamblin <trevor.gamblin@windriver.com>2019-12-05 11:55:19 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-20 13:00:28 +0000
commit0f54a2fd69c9513cb857a3a0436bd8b75332f4e9 (patch)
tree21f0ce1dbf1ff1e070e2b1b304a4c36c960ab194
parent9b312bca47e22cc3a93df356dcae73a8ee4a6787 (diff)
downloadpoky-0f54a2fd69c9513cb857a3a0436bd8b75332f4e9.tar.gz
oescripts.py: use unittest.SkipUnless for class skip
Yocto Bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13663 Prior to this fix, the try/except block in OEScriptTests' setUpClass did both the import and the raise unittest.SkipTest for the subsequent OEPybootchartguyTests. The consequence of the this meant that, when cairo was not available on the test host, the raise was counted only once as a class setup issue, instead of once for each of the tests to be run, resulting in incorrect skip counts in the test results. Instead of raising unittest.SkipTest in setUpClass, the more proper method is to use the unittest.skipUnless method along with importlib.util.find_spec to check for the presence of the python3-cairo module. This allows the entire class to be skipped if cairo is not present, while also correctly passing along the skip state for each of the class's tests, and avoiding the UNKNOWN results to appear in cases where the -j option was provided to oe-selftest, but the tests were still skipped. (From OE-Core rev: 10c2216cb6fb61c74babd8bd17cb3481754b7475) Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/oescripts.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py
index 41cbe04808..2f18d8f29c 100644
--- a/meta/lib/oeqa/selftest/cases/oescripts.py
+++ b/meta/lib/oeqa/selftest/cases/oescripts.py
@@ -4,6 +4,7 @@
4 4
5import os 5import os
6import shutil 6import shutil
7import importlib
7import unittest 8import unittest
8from oeqa.selftest.case import OESelftestTestCase 9from oeqa.selftest.case import OESelftestTestCase
9from oeqa.selftest.cases.buildhistory import BuildhistoryBase 10from oeqa.selftest.cases.buildhistory import BuildhistoryBase
@@ -33,15 +34,13 @@ class BuildhistoryDiffTests(BuildhistoryBase):
33 if expected_endlines: 34 if expected_endlines:
34 self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) 35 self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines))
35 36
37@unittest.skipUnless(importlib.util.find_spec("cairo"), "Python cairo module is not present")
36class OEScriptTests(OESelftestTestCase): 38class OEScriptTests(OESelftestTestCase):
37 39
38 @classmethod 40 @classmethod
39 def setUpClass(cls): 41 def setUpClass(cls):
40 super(OEScriptTests, cls).setUpClass() 42 super(OEScriptTests, cls).setUpClass()
41 try: 43 import cairo
42 import cairo
43 except ImportError:
44 raise unittest.SkipTest('Python module cairo is not present')
45 bitbake("core-image-minimal -c rootfs -f") 44 bitbake("core-image-minimal -c rootfs -f")
46 cls.tmpdir = get_bb_var('TMPDIR') 45 cls.tmpdir = get_bb_var('TMPDIR')
47 cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1] 46 cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1]