[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6054/8267] oeqa/core: Add support for run tests by module, class and name
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 6054/8267] oeqa/core: Add support for run tests by module, class and name
- Date: Sun, 17 Dec 2017 04:18:16 +0000 (UTC)
commit c746ee11eca0f09d71e23986fb77392777e255cd
Author: Aníbal Limón <anibal limon linux intel com>
Date: Fri May 26 15:37:45 2017 -0500
oeqa/core: Add support for run tests by module, class and name
This will enable only run certain module tests and filter by
class and test name.
(From OE-Core rev: 0f7531803aa6ffef2b7c5be9acee3efe7d2974ef)
Signed-off-by: Aníbal Limón <anibal limon linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta/lib/oeqa/core/context.py | 6 ++--
meta/lib/oeqa/core/loader.py | 66 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 68 insertions(+), 4 deletions(-)
---
diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index bc958d0..28ae017 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -85,9 +85,9 @@ class OETestContextExecutor(object):
help="results output log, default: %s" % self.default_output_log)
group = self.parser.add_mutually_exclusive_group()
- group.add_argument('--run-tests', action='store',
+ group.add_argument('--run-tests', action='store', nargs='+',
default=self.default_tests,
- help="tests to run in <module>[.<class>[.<name>]] format. Just works for modules now")
+ help="tests to run in <module>[.<class>[.<name>]]")
group.add_argument('--list-tests', action='store',
choices=('module', 'class', 'name'),
help="lists available tests")
@@ -136,7 +136,7 @@ class OETestContextExecutor(object):
self.tc_kwargs['init']['td'] = {}
if args.run_tests:
- self.tc_kwargs['load']['modules'] = args.run_tests.split()
+ self.tc_kwargs['load']['modules'] = args.run_tests
else:
self.tc_kwargs['load']['modules'] = None
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 63a1703..bffb2da 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -29,6 +29,51 @@ def _find_duplicated_modules(suite, directory):
if path:
raise ImportError("Duplicated %s module found in %s" % (module, path))
+def _built_modules_dict(modules):
+ modules_dict = {}
+
+ if modules == None:
+ return modules_dict
+
+ for m in modules:
+ ms = m.split('.')
+
+ if len(ms) == 1:
+ module_name = ms[0]
+ if not module_name in modules_dict:
+ modules_dict[module_name] = {}
+ elif len(ms) == 2:
+ module_name = ms[0]
+ class_name = ms[1]
+ if not module_name in modules_dict:
+ modules_dict[module_name] = {}
+ if not class_name in modules_dict[module_name]:
+ modules_dict[module_name][class_name] = []
+ elif len(ms) == 3:
+ module_name = ms[0]
+ class_name = ms[1]
+ test_name = ms[2]
+
+ if not module_name in modules_dict:
+ modules_dict[module_name] = {}
+ if not class_name in modules_dict[module_name]:
+ modules_dict[module_name][class_name] = []
+ if not test_name in modules_dict[module_name][class_name]:
+ modules_dict[module_name][class_name].append(test_name)
+ elif len(ms) >= 4:
+ module_name = '.'.join(ms[0:-2])
+ class_name = ms[-2]
+ test_name = ms[-1]
+
+ if not module_name in modules_dict:
+ modules_dict[module_name] = {}
+ if not class_name in modules_dict[module_name]:
+ modules_dict[module_name][class_name] = []
+ if not test_name in modules_dict[module_name][class_name]:
+ modules_dict[module_name][class_name].append(test_name)
+
+ return modules_dict
+
class OETestLoader(unittest.TestLoader):
caseClass = OETestCase
@@ -39,7 +84,8 @@ class OETestLoader(unittest.TestLoader):
filters, *args, **kwargs):
self.tc = tc
- self.modules = modules
+ self.modules = _built_modules_dict(modules)
+
self.tests = tests
self.modules_required = modules_required
@@ -116,6 +162,24 @@ class OETestLoader(unittest.TestLoader):
"""
Returns True if test case must be filtered, False otherwise.
"""
+ # Filters by module.class.name
+ module_name = case.__module__
+ class_name = case.__class__.__name__
+ test_name = case._testMethodName
+
+ if self.modules:
+ if not module_name in self.modules:
+ return True
+
+ if self.modules[module_name]:
+ if not class_name in self.modules[module_name]:
+ return True
+
+ if self.modules[module_name][class_name]:
+ if test_name not in self.modules[module_name][class_name]:
+ return True
+
+ # Decorator filters
if self.filters:
filters = self.filters.copy()
case_decorators = [cd for cd in case.decorators
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]