From e1705791e6fa7d80d14110cabbc6979d497e9e12 Mon Sep 17 00:00:00 2001 From: Andrew Yourtchenko Date: Wed, 19 Mar 2025 14:11:44 +0000 Subject: tests: allow to define SKIP_TESTS in a similar fashion to TEST This change adds the possibility to specify the tests to skip from the selected set of tests. This allows to construct test sets "everything except foo and bar" that are tedious to make otherwise. Type: improvement Change-Id: I0862031baf22fef926554873a88a068dfc8f0623 Signed-off-by: Andrew Yourtchenko --- test/run_tests.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'test/run_tests.py') diff --git a/test/run_tests.py b/test/run_tests.py index 66e0ee4db39..166f5d3cd48 100644 --- a/test/run_tests.py +++ b/test/run_tests.py @@ -685,8 +685,9 @@ def filter_tests(tests, filter_cb): class FilterByTestOption: - def __init__(self, filters): + def __init__(self, filters, skip_filters): self.filters = filters + self.skip_filters = skip_filters def __call__(self, file_name, class_name, func_name): def test_one( @@ -716,6 +717,21 @@ class FilterByTestOption: class_name, func_name, ): + for ( + x_filter_file_name, + x_filter_class_name, + x_filter_func_name, + ) in self.skip_filters: + if test_one( + x_filter_file_name, + x_filter_class_name, + x_filter_func_name, + file_name, + class_name, + func_name, + ): + # If the test matches the excluded tests, do not run it + return False return True return False @@ -976,6 +992,11 @@ if __name__ == "__main__": print("Running tests using custom test runner.") filters = [(parse_test_filter(f)) for f in config.filter.split(",")] + skip_filters = [(parse_test_filter(f)) for f in config.skip_filter.split(",")] + # Remove the (None, None, None) triplet that gets pushed by default + skip_filters = [ + triplet for triplet in skip_filters if triplet != (None, None, None) + ] print( "Selected filters: ", @@ -984,8 +1005,15 @@ if __name__ == "__main__": for filter_file, filter_class, filter_func in filters ), ) + print( + "Selected skip filters: ", + "|".join( + f"file={filter_file}, class={filter_class}, function={filter_func}" + for filter_file, filter_class, filter_func in skip_filters + ), + ) - filter_cb = FilterByTestOption(filters) + filter_cb = FilterByTestOption(filters, skip_filters) cb = SplitToSuitesCallback(filter_cb) for d in config.test_src_dir: -- cgit