summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
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 22:24:03 +0000
commitb40d80993e3a36ca5b59970e04e46dd7884e7599 (patch)
tree163b54aebca3e7fbb8722b45a8a8146481ea71ab /meta/lib/oeqa
parentce71ef3ee5ccd11fb276b9272d7b3cdd0c7292b0 (diff)
downloadpoky-b40d80993e3a36ca5b59970e04e46dd7884e7599.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. (From OE-Core rev: 80db3d999ae26d298d9d5418a32b11a4f27af9d5) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-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 @@
2# Released under the MIT license (see COPYING.MIT) 2# Released under the MIT license (see COPYING.MIT)
3 3
4import os 4import os
5import re
5import sys 6import sys
6import unittest 7import unittest
7import inspect 8import inspect
@@ -39,42 +40,19 @@ def _built_modules_dict(modules):
39 if modules == None: 40 if modules == None:
40 return modules_dict 41 return modules_dict
41 42
42 for m in modules: 43 for module in modules:
43 ms = m.split('.') 44 # Assumption: package and module names do not contain upper case
44 45 # characters, whereas class names do
45 if len(ms) == 1: 46 m = re.match(r'^([^A-Z]+)(?:\.([A-Z][^.]*)(?:\.([^.]+))?)?$', module)
46 module_name = ms[0] 47
47 if not module_name in modules_dict: 48 module_name, class_name, test_name = m.groups()
48 modules_dict[module_name] = {} 49
49 elif len(ms) == 2: 50 if module_name and module_name not in modules_dict:
50 module_name = ms[0] 51 modules_dict[module_name] = {}
51 class_name = ms[1] 52 if class_name and class_name not in modules_dict[module_name]:
52 if not module_name in modules_dict: 53 modules_dict[module_name][class_name] = []
53 modules_dict[module_name] = {} 54 if test_name and test_name not in modules_dict[module_name][class_name]:
54 if not class_name in modules_dict[module_name]: 55 modules_dict[module_name][class_name].append(test_name)
55 modules_dict[module_name][class_name] = []
56 elif len(ms) == 3:
57 module_name = ms[0]
58 class_name = ms[1]
59 test_name = ms[2]
60
61 if not module_name in modules_dict:
62 modules_dict[module_name] = {}
63 if not class_name in modules_dict[module_name]:
64 modules_dict[module_name][class_name] = []
65 if not test_name in modules_dict[module_name][class_name]:
66 modules_dict[module_name][class_name].append(test_name)
67 elif len(ms) >= 4:
68 module_name = '.'.join(ms[0:-2])
69 class_name = ms[-2]
70 test_name = ms[-1]
71
72 if not module_name in modules_dict:
73 modules_dict[module_name] = {}
74 if not class_name in modules_dict[module_name]:
75 modules_dict[module_name][class_name] = []
76 if not test_name in modules_dict[module_name][class_name]:
77 modules_dict[module_name][class_name].append(test_name)
78 56
79 return modules_dict 57 return modules_dict
80 58