Skip to content

Commit fe02e0f

Browse files
keeskuba-moo
authored andcommitted
Tester: Add optional include/exclude and test dir config
By default, all tests will be run for a given Tester. Add "include" and "exclude" options to the config file "tests" section. For example: [tests] include = series/patch_count, series/cover_letter, patch/signed If "include" is specified, only the listed tests are run. If "exclude" is specified, all tests except the listed ones are run. By default, the top-level "tests" directory is found in "../../", but now this can be set via "tests" config of the "dirs" section. For example: [dirs] trees: /home/kees/code/linux-build/nipa Signed-off-by: Kees Cook <[email protected]>
1 parent 581b98f commit fe02e0f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

core/tester.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@
1212
from core import Test, PullError
1313

1414

15-
def load_tests(tests_dir, name):
15+
def load_tests(config, name):
1616
core.log_open_sec(name.capitalize() + " tests")
17-
tests_subdir = os.path.join(tests_dir, name)
17+
tests_subdir = os.path.join(config.get('dirs', 'tests'), name)
18+
include = [x.strip() for x in config.get('tests', 'include', fallback="").split(',')]
19+
exclude = [x.strip() for x in config.get('tests', 'exclude', fallback="").split(',')]
1820
tests = []
1921
for td in os.listdir(tests_subdir):
20-
tests.append(Test(os.path.join(tests_subdir, td), td))
22+
test = f'{name}/{td}'
23+
if test not in exclude and (len(include) == 0 or test in include):
24+
core.log(f"Adding test {test}")
25+
tests.append(Test(os.path.join(tests_subdir, td), td))
26+
else:
27+
core.log(f"Skipped test {test}")
2128
core.log_end_sec()
2229

2330
return tests
@@ -74,9 +81,10 @@ def run(self) -> None:
7481
os.makedirs(self.result_dir)
7582

7683
tests_dir = os.path.abspath(core.CORE_DIR + "../../tests")
84+
config.set('dirs', 'tests', config.get('dirs', 'tests', fallback=tests_dir))
7785

78-
self.series_tests = load_tests(tests_dir, "series")
79-
self.patch_tests = load_tests(tests_dir, "patch")
86+
self.series_tests = load_tests(config, "series")
87+
self.patch_tests = load_tests(config, "patch")
8088
core.log_end_sec()
8189

8290
while not self.should_die:

0 commit comments

Comments
 (0)