diff options
-rw-r--r-- | meta/lib/oeqa/core/loader.py | 50 |
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 | ||
4 | import os | 4 | import os |
5 | import re | ||
5 | import sys | 6 | import sys |
6 | import unittest | 7 | import unittest |
7 | import inspect | 8 | import 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 | ||