aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2017-09-29 18:06:11 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-08 19:54:22 +0000
commit80db3d999ae26d298d9d5418a32b11a4f27af9d5 (patch)
tree53c64058eff4e2295393d41728cf832a201ca8dd /meta/lib
parent842f3beb211eb0a398b37c50d433a93b86964f6b (diff)
downloadopenembedded-core-contrib-80db3d999ae26d298d9d5418a32b11a4f27af9d5.tar.gz
oeqa/core/loader: Make _built_modules_dict() support packages correctly
For test modules in a package, e.g., oelib.license, running `oe-selftest -r oelib.license` or `oe-selftest -r oelib.license.TestSimpleCombinations` would fail with a message that the specified test cases could not be found. This was due to the parsing in _built_modules_dict(), which failed to distinguish between <package>.<module>.<class> and <module>.<class>.<testcase> and treated both cases as the latter. Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/core/loader.py50
1 files changed, 14 insertions, 36 deletions
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 332086a13d..975a081ba4 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -2,6 +2,7 @@
# Released under the MIT license (see COPYING.MIT)
import os
+import re
import sys
import unittest
import inspect
@@ -39,42 +40,19 @@ def _built_modules_dict(modules):
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)
+ for module in modules:
+ # Assumption: package and module names do not contain upper case
+ # characters, whereas class names do
+ m = re.match(r'^([^A-Z]+)(?:\.([A-Z][^.]*)(?:\.([^.]+))?)?$', module)
+
+ module_name, class_name, test_name = m.groups()
+
+ if module_name and module_name not in modules_dict:
+ modules_dict[module_name] = {}
+ if class_name and class_name not in modules_dict[module_name]:
+ modules_dict[module_name][class_name] = []
+ if test_name and test_name not in modules_dict[module_name][class_name]:
+ modules_dict[module_name][class_name].append(test_name)
return modules_dict