From 9bbf2dd07c1adbb3fd129d1fac824c369d3286cf Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sat, 1 May 2021 13:31:37 +0200 Subject: Add validation for --only in `run_project_tests.py` This now gives a clear error rather than silently passes for unrecognized categories, like: python run_project_tests.py --only nonexisting or python run_project_tests.py --only objc # should be 'objective c' --- run_project_tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_project_tests.py b/run_project_tests.py index 2883e7e54..fcb871655 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -999,7 +999,7 @@ def detect_tests_to_run(only: T.Dict[str, T.List[str]], use_tmp: bool) -> T.List self.category = category # category name self.subdir = subdir # subdirectory self.skip = skip # skip condition - self.stdout_mandatory = stdout_mandatory # expected stdout is mandatory for tests in this categroy + self.stdout_mandatory = stdout_mandatory # expected stdout is mandatory for tests in this category all_tests = [ TestCategory('cmake', 'cmake', not shutil.which('cmake') or (os.environ.get('compiler') == 'msvc2015' and under_ci)), @@ -1036,6 +1036,8 @@ def detect_tests_to_run(only: T.Dict[str, T.List[str]], use_tmp: bool) -> T.List assert categories == ALL_TESTS, 'argparse("--only", choices=ALL_TESTS) need to be updated to match all_tests categories' if only: + for key in only.keys(): + assert key in categories, 'key `{}` is not a recognized category'.format(key) all_tests = [t for t in all_tests if t.category in only.keys()] gathered_tests = [(t.category, gather_tests(Path('test cases', t.subdir), t.stdout_mandatory, only[t.category]), t.skip) for t in all_tests] -- cgit v1.2.3