public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: jwang <jing.j.wang@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 3/4] meta: use baserunner in oetest
Date: Tue, 13 Sep 2016 09:17:34 +0800	[thread overview]
Message-ID: <1473729455-32649-3-git-send-email-jing.j.wang@intel.com> (raw)
In-Reply-To: <1473729455-32649-1-git-send-email-jing.j.wang@intel.com>

From: zjh <junhuix.zhang@intel.com>

enable two features from baserunner:
1. loadtest
2. read test cases from manifest file

Signed-off-by: zjh <junhuix.zhang@intel.com>
---
 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 4a740fb..9211cec 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")
 
@@ -203,8 +205,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()
@@ -223,6 +227,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):
@@ -329,9 +336,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
@@ -376,9 +381,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
 
@@ -387,11 +392,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):
-- 
2.1.4



  parent reply	other threads:[~2016-09-13  1:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13  1:17 [PATCH 1/4] meta: introduce a small baserunner framework jwang
2016-09-13  1:17 ` [PATCH 2/4] meta: implement key baserunner features jwang
2016-09-15 13:15   ` Joshua Lock
2016-09-13  1:17 ` jwang [this message]
2016-09-15 13:15   ` [PATCH 3/4] meta: use baserunner in oetest Joshua Lock
2016-09-13  1:17 ` [PATCH 4/4] meta: modify runexported script to inherit the features from baserunner jwang
2016-09-15 13:15 ` [PATCH 1/4] meta: introduce a small baserunner framework Joshua Lock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473729455-32649-3-git-send-email-jing.j.wang@intel.com \
    --to=jing.j.wang@intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox