|
14 | 14 | from lib.tarantool_server import Test
|
15 | 15 | from lib.tarantool_server import TestExecutionError
|
16 | 16 | from lib.tarantool_server import TarantoolServer
|
| 17 | +from lib.utils import find_tags |
17 | 18 |
|
18 | 19 |
|
19 | 20 | def timeout_handler(process, test_timeout):
|
@@ -141,18 +142,46 @@ def verify_luatest_exe(cls):
|
141 | 142 | def find_tests(test_suite, suite_path):
|
142 | 143 | """Looking for *_test.lua, which are can be executed by luatest."""
|
143 | 144 |
|
144 |
| - def patterned(test, patterns): |
145 |
| - answer = [] |
146 |
| - for i in patterns: |
147 |
| - if test.name.find(i) != -1: |
148 |
| - answer.append(test) |
149 |
| - return answer |
150 |
| - |
| 145 | + # TODO: Investigate why this old hack is needed and drop |
| 146 | + # it if possible (move the assignment to test_suite.py). |
| 147 | + # |
| 148 | + # cdc70f94701f suggests that it is related to the out of |
| 149 | + # source build. |
151 | 150 | test_suite.ini['suite'] = suite_path
|
152 |
| - tests = glob.glob(os.path.join(suite_path, '*_test.lua')) |
153 | 151 |
|
154 |
| - tests = Server.exclude_tests(tests, test_suite.args.exclude) |
155 |
| - test_suite.tests = [LuatestTest(k, test_suite.args, test_suite.ini) |
156 |
| - for k in sorted(tests)] |
157 |
| - test_suite.tests = sum([patterned(x, test_suite.args.tests) |
158 |
| - for x in test_suite.tests], []) |
| 152 | + # A pattern here means just a substring to find in a test |
| 153 | + # name. |
| 154 | + include_patterns = Options().args.tests |
| 155 | + exclude_patterns = Options().args.exclude |
| 156 | + |
| 157 | + accepted_tags = Options().args.tags |
| 158 | + |
| 159 | + tests = [] |
| 160 | + for test_name in glob.glob(os.path.join(suite_path, '*_test.lua')): |
| 161 | + # If neither of the include patterns are substrings of |
| 162 | + # the given test name, skip the test. |
| 163 | + if not any(p in test_name for p in include_patterns): |
| 164 | + continue |
| 165 | + |
| 166 | + # If at least one of the exclude patterns is a |
| 167 | + # substring of the given test name, skip the test. |
| 168 | + if any(p in test_name for p in exclude_patterns): |
| 169 | + continue |
| 170 | + |
| 171 | + # If --tags <...> CLI option is provided... |
| 172 | + if accepted_tags: |
| 173 | + tags = find_tags(test_name) |
| 174 | + # ...and the test has neither of the given tags, |
| 175 | + # skip the test. |
| 176 | + if not any(t in accepted_tags for t in tags): |
| 177 | + continue |
| 178 | + |
| 179 | + # Add the test to the execution list otherwise. |
| 180 | + tests.append(LuatestTest(test_name, test_suite.args, test_suite.ini)) |
| 181 | + |
| 182 | + tests.sort(key=lambda t: t.name) |
| 183 | + |
| 184 | + # TODO: Don't modify a test suite object's field from |
| 185 | + # another object directly. It is much better to just |
| 186 | + # return a list of tests from this method. |
| 187 | + test_suite.tests = tests |
0 commit comments