From 7ec48a6ed17e70c7f436e9eaffc9818e86937460 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Thu, 9 Oct 2025 10:46:25 +0200 Subject: [PATCH] Benchmark: allow exclusion filters using ! This allows exclusions to be set in the `tests` filter for the benchmarks using the exclamation mark. Exclusions apply *after* inclusions ie: tests = ['*', '!victor', '!koro'] would select all available tests then specifically exclude victor and koro, while: tests = ['!victor'] would just exclude victor, since nothing is marked for inclusion no tests will be run. tests = ['!victor','bmw27,'victor'] would exclude victor, but include bmw27 and victor but as victor was marked for exclusion only bmw27 will be ran. Requested by bart in #146019 Pull Request: https://projects.blender.org/blender/blender/pulls/147588 --- tests/performance/api/test.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/performance/api/test.py b/tests/performance/api/test.py index bb5443150c8..28636fb7a5f 100644 --- a/tests/performance/api/test.py +++ b/tests/performance/api/test.py @@ -65,11 +65,22 @@ class TestCollection: continue test_name = test.name() - found = False + + included = False + excluded = False + for name_filter in names_filter: - if fnmatch.fnmatch(test_name, name_filter): - found = True - if not found: + is_exclusion = name_filter.startswith('!') + pattern = name_filter[1:] if is_exclusion else name_filter + + if fnmatch.fnmatch(test_name, pattern): + if is_exclusion: + excluded = True + break + else: + included = True + + if not included or excluded: continue self.tests.append(test)