Skip to contentSkip to conversation

testsdk.bbclass: check python module testools and subunit

PATCH In review Robert Yang 1 participant 3 messages Jul 27, 2018

lore
Share & tools
lore
#0 lore raw

cover testsdk.bbclass: check python module testools and subunit

The following changes since commit 364449251ffe4ff2c11acaa258edcec244c38818:

classes/package: fix variable name in comment (2018-07-26 16:55:21 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/testtools
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/testtools

Robert Yang (1):
testsdk.bbclass: check python module testools and subunit

 meta/classes/testsdk.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 testsdk.bbclass: check python module testools and subunit

The testools 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 testools or subunit, the testcases will run serially

---
 meta/classes/testsdk.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)
meta/classes/testsdk.bbclass +6 -0
index 5df17bf..4f86998 100644
@@ -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 testools, subunit
+        except ImportError:
+            bb.warn("Failed to import testools or subunit, the testcases will run serially")
+            processes = None
 
     sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
     bb.utils.remove(sdk_dir, True)
Signature · 1 line
2.7.4
#2 lore raw
Quoted 20 lines · Robert Yang

The testools 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 testools or subunit, the testcases will run serially

---
  meta/classes/testsdk.bbclass | 6 ++++++
  1 file changed, 6 insertions(+)
meta/classes/testsdk.bbclass +0 -0
index 5df17bf..4f86998 100644

meta/classes/testsdk.bbclass def testsdk_main(d): · line 50

Quoted 8 lines
meta/classes/testsdk.bbclass +5 -0
@@ -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 testools, subunit
+        except ImportError:
+            bb.warn("Failed to import testools or subunit, the testcases will run serially")

Sorry, typos, they should be "testtools" (lacks of a t), I fixed them in the repo, also fixed in the commit message.

// Robert

Quoted 5 lines
meta/classes/testsdk.bbclass +1 -0
+            processes = None
 
      sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
      bb.utils.remove(sdk_dir, True)