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
This commit is contained in:
Ray Molenkamp
2025-10-09 10:46:25 +02:00
committed by Bart van der Braak
parent 87fb5aa303
commit 7ec48a6ed1

View File

@@ -65,11 +65,22 @@ class TestCollection:
continue continue
test_name = test.name() test_name = test.name()
found = False
included = False
excluded = False
for name_filter in names_filter: for name_filter in names_filter:
if fnmatch.fnmatch(test_name, name_filter): is_exclusion = name_filter.startswith('!')
found = True pattern = name_filter[1:] if is_exclusion else name_filter
if not found:
if fnmatch.fnmatch(test_name, pattern):
if is_exclusion:
excluded = True
break
else:
included = True
if not included or excluded:
continue continue
self.tests.append(test) self.tests.append(test)