[OE-core] [PATCH 3/4] meta: use baserunner in oetest
Joshua Lock
joshua.g.lock at linux.intel.com
Thu Sep 15 13:15:48 UTC 2016
On Tue, 2016-09-13 at 09:17 +0800, jwang wrote:
> From: zjh <junhuix.zhang at intel.com>
>
> enable two features from baserunner:
> 1. loadtest
> 2. read test cases from manifest file
>
> Signed-off-by: zjh <junhuix.zhang at 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
This is a funny variable, when would it not be True and why? Could we
add a comment here about what the variable is for?
Should it be an argument passed at object construction, as it's denoted
as internal by the _ prefix?
> 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()
If we don't configure during __init__() when do we do it? Why might we
not do it during __init__() ?
> +
> # 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))
We appear to be using a non-public instance variable, is there
something else we could be using here to get the list of tests?
>
> - 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
>
More information about the Openembedded-core
mailing list