]> code.ossystems Code Review - openembedded-core.git/commitdiff
testsdk.bbclass: check python module testtools and subunit
authorRobert Yang <liezhi.yang@windriver.com>
Fri, 27 Jul 2018 03:17:36 +0000 (11:17 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 30 Jul 2018 11:44:28 +0000 (12:44 +0100)
The testtools or subunit is not part of python's standard library, so check them
before use.

Fixed when they are not installed on host:
$ bitbake core-image-minimal -ctestsdk
Exception: ImportError: No module named 'testtools'

Now it can run with a warning:
WARNING: core-image-minimal-1.0-r0 do_testsdk: Failed to import testtools or subunit, the testcases will run serially

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/testsdk.bbclass

index 5df17bfa9e3a00c7cb241e7214c1cd7e76832ca9..d3f475d22be77301341e32da7f2328159b8ab757 100644 (file)
@@ -43,6 +43,12 @@ def testsdk_main(d):
         d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"))
 
     processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS")
+    if processes:
+        try:
+            import testtools, subunit
+        except ImportError:
+            bb.warn("Failed to import testtools or subunit, the testcases will run serially")
+            processes = None
 
     sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
     bb.utils.remove(sdk_dir, True)