Allowed empty suites in test.py/bench.py

This happens when you need to comment out an entire suite due to
temporary changes.
This commit is contained in:
Christopher Haster
2023-02-20 13:43:30 -06:00
parent b887365fcb
commit a20625be7c
2 changed files with 47 additions and 45 deletions
+22 -21
View File
@@ -171,7 +171,7 @@ class BenchSuite:
# sort in case toml parsing did not retain order
case_linenos.sort()
cases = config.pop('cases')
cases = config.pop('cases', {})
for (lineno, name), (nlineno, _) in it.zip_longest(
case_linenos, case_linenos[1:],
fillvalue=(float('inf'), None)):
@@ -209,7 +209,7 @@ class BenchSuite:
args=args))
# combine per-case defines
self.defines = set.union(*(
self.defines = set.union(set(), *(
set(case.defines) for case in self.cases))
for k in config.keys():
@@ -425,26 +425,27 @@ def compile(bench_paths, **args):
f.writeln(4*' '+'},')
f.writeln(4*' '+'.define_count = '
'BENCH_IMPLICIT_DEFINE_COUNT+%d,' % len(suite.defines))
f.writeln(4*' '+'.cases = (const struct bench_case[]){')
for case in suite.cases:
# create case structs
f.writeln(8*' '+'{')
f.writeln(12*' '+'.name = "%s",' % case.name)
f.writeln(12*' '+'.path = "%s",' % case.path)
f.writeln(12*' '+'.flags = 0,')
f.writeln(12*' '+'.permutations = %d,'
% len(case.permutations))
if case.defines:
f.writeln(12*' '+'.defines '
'= (const bench_define_t*)__bench__%s__defines,'
if suite.cases:
f.writeln(4*' '+'.cases = (const struct bench_case[]){')
for case in suite.cases:
# create case structs
f.writeln(8*' '+'{')
f.writeln(12*' '+'.name = "%s",' % case.name)
f.writeln(12*' '+'.path = "%s",' % case.path)
f.writeln(12*' '+'.flags = 0,')
f.writeln(12*' '+'.permutations = %d,'
% len(case.permutations))
if case.defines:
f.writeln(12*' '+'.defines '
'= (const bench_define_t*)__bench__%s__defines,'
% (case.name))
if suite.if_ is not None or case.if_ is not None:
f.writeln(12*' '+'.filter = __bench__%s__filter,'
% (case.name))
f.writeln(12*' '+'.run = __bench__%s__run,'
% (case.name))
if suite.if_ is not None or case.if_ is not None:
f.writeln(12*' '+'.filter = __bench__%s__filter,'
% (case.name))
f.writeln(12*' '+'.run = __bench__%s__run,'
% (case.name))
f.writeln(8*' '+'},')
f.writeln(4*' '+'},')
f.writeln(8*' '+'},')
f.writeln(4*' '+'},')
f.writeln(4*' '+'.case_count = %d,' % len(suite.cases))
f.writeln('};')
f.writeln()