]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa: avoid class setup method to run when skipping the whole class
authorChen Qi <Qi.Chen@windriver.com>
Fri, 21 Jun 2019 01:18:03 +0000 (09:18 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 21 Jun 2019 14:30:56 +0000 (15:30 +0100)
For now, even if we have specified to skip the whole module/class via
command line, e.g., `oe-selftest -R gotoolchain', the class setup method
is still run. This at least results in unnecessary builds, and at worst
results in ERROR, if the setup method fails.

So improve the skipping mechanism to avoid class setup method to run
when specified to skip.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/core/case.py
meta/lib/oeqa/core/context.py

index 54977c809fb4e04c73e2718234252d8060e8e825..aca144e9dcce7efcae3b739409b6aa6e501289e6 100644 (file)
@@ -32,6 +32,8 @@ class OETestCase(unittest.TestCase):
     @classmethod
     def _oeSetUpClass(clss):
         _validate_td_vars(clss.td, clss.td_vars, "class")
+        if hasattr(clss, 'setUpHooker') and callable(getattr(clss, 'setUpHooker')):
+            clss.setUpHooker()
         clss.setUpClassMethod()
 
     @classmethod
index 7882697e28ce8b12accb1f5c2bf1af947102a39f..68819cc3386e21f0be9f7f2b5e2afb12669fc123 100644 (file)
@@ -50,10 +50,18 @@ class OETestContext(object):
             def func():
                 raise unittest.SkipTest(skipmsg)
             return func
+        class_ids = {}
         for test in self.suites:
+            if test.__class__ not in class_ids:
+                class_ids[test.__class__] = '.'.join(test.id().split('.')[:-1])
             for skip in skips:
                 if (test.id()+'.').startswith(skip+'.'):
                     setattr(test, 'setUp', skipfuncgen('Skip by the command line argument "%s"' % skip))
+        for tclass in class_ids:
+            cid = class_ids[tclass]
+            for skip in skips:
+                if (cid + '.').startswith(skip + '.'):
+                    setattr(tclass, 'setUpHooker', skipfuncgen('Skip by the command line argument "%s"' % skip))
 
     def loadTests(self, module_paths, modules=[], tests=[],
             modules_manifest="", modules_required=[], filters={}):