[oe-commits] [openembedded-core] 07/11: meta: use baserunner in oetest

git at git.openembedded.org git at git.openembedded.org
Wed Sep 14 21:42:47 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit a45ff628103133bfad5c866f1691dbbef36d4114
Author: zjh <junhuix.zhang at intel.com>
AuthorDate: Tue Sep 13 09:17:34 2016 +0800

    meta: use baserunner in oetest
    
    enable two features from baserunner:
    1. loadtest
    2. read test cases from manifest file
    
    Signed-off-by: zjh <junhuix.zhang at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/oetest.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index cf7e862..eb19cb6 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -28,6 +28,8 @@ except ImportError:
     pass
 from oeqa.utils.decorators import LogResults, gettag, getResults
 from oeqa.utils import avoid_paths_in_environ
+from base.baserunner import TestRunnerBase
+
 
 logger = logging.getLogger("BitBake")
 
@@ -212,8 +214,10 @@ def custom_verbose(msg, *args, **kwargs):
             logger.info(_buffer_logger.rstrip("\n"), *args, **kwargs)
         _buffer_logger = ""
 
-class TestContext(object):
+class TestContext(TestRunnerBase):
+    _configure_in_init = True
     def __init__(self, d, exported=False):
+        super(TestContext, self).__init__(self)
         self.d = d
 
         self.testsuites = self._get_test_suites()
@@ -232,6 +236,9 @@ class TestContext(object):
         self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
         self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
 
+        if self._configure_in_init:
+            self.configure()
+
     # get testcase list from specified file
     # if path is a relative path, then relative to build/conf/
     def _read_testlist(self, fpath, builddir):
@@ -336,9 +343,7 @@ class TestContext(object):
     def loadTests(self):
         setattr(oeTest, "tc", self)
 
-        testloader = unittest.TestLoader()
-        testloader.sortTestMethodsUsing = None
-        suites = [testloader.loadTestsFromName(name) for name in self.testslist]
+        suites = self.loadtest(self.testslist)
         suites = filterByTagExp(suites, getattr(self, "tagexp", None))
 
         # Determine dependencies between suites by looking for @skipUnlessPassed
@@ -383,9 +388,9 @@ class TestContext(object):
         def cmpfunc(a, b):
             return cmp((a.depth, a.index), (b.depth, b.index))
 
-        suites.sort(key=functools.cmp_to_key(cmpfunc))
+        suites._tests.sort(key=functools.cmp_to_key(cmpfunc))
 
-        self.suite = testloader.suiteClass(suites)
+        self.suite = suites
 
         return self.suite
 
@@ -394,11 +399,10 @@ class TestContext(object):
         if hasattr(self, "tagexp") and self.tagexp:
             logger.info("Filter test cases by tags: %s" % self.tagexp)
         logger.info("Found %s tests" % self.suite.countTestCases())
-        runner = unittest.TextTestRunner(verbosity=2)
         if 'bb' in sys.modules:
-            runner.stream.write = custom_verbose
-
-        return runner.run(self.suite)
+            self.runner.stream.write = custom_verbose
+        self.start(self.suite)
+        return self.result()
 
 class RuntimeTestContext(TestContext):
     def __init__(self, d, target, exported=False):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list