allow filtering tests to run

This commit is contained in:
Ivan Avdeev 2023-11-27 10:30:17 -05:00
parent 6c65b1dfac
commit b09edd28fe
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
# TODO load all saves from the save/ dir
saves = [
'brush2_01',
'brush_01',
@ -23,11 +24,22 @@ displays = {
import argparse
def test_list(arg: str) -> [str]:
items = arg.split(',')
tests = []
for item in items:
# TODO regex?
if not item in saves:
raise argparse.ArgumentTypeError(f'Test {item} is not available. Available tests are: {saves}')
tests.append(item)
return tests
parser = argparse.ArgumentParser(description='Generate scripts and makefiles for rendertest')
parser.add_argument('--script', '-s', type=argparse.FileType('w'), help='Console script for generating images')
parser.add_argument('--tests', '-t', type=test_list, default=saves, help='Run only these tests')
args = parser.parse_args()
def make_script(file):
def make_script(file, tests: [str]):
header = '''sv_cheats 1
developer 0
m_ignore 1
@ -42,18 +54,24 @@ rt_debug_fixed_random_seed 31337
file.write(header)
for save in saves:
for test in tests:
screenshot_base = 'rendertest/'
file.write(f'load rendertest_{save}\n')
file.write(f'load rendertest_{test}\n')
file.write(f'wait 4; echo DONE WAIT4; playersonly; wait 11\n')
# for i in range(13):
# file.write(f'echo FRAME {i+4}; wait 1;\n')
for name, display in displays.items():
file.write(f'rt_debug_display_only "{display}"; screenshot {screenshot_base}{save}_{name}.tga; wait 1\n')
file.write(f'rt_debug_display_only "{display}"; screenshot {screenshot_base}{test}_{name}.tga; wait 1\n')
file.write('\n')
file.write('quit\n')
if args.script:
print(f'Generating script {args.script.name}')
make_script(args.script)
make_script(args.script, args.tests)
# TODO:
# - single command to do everything: compile, run, and compare
# - filter by specific save files
# - parallel processing
# - HTML report

View File

@ -63,6 +63,7 @@ convert_png() {
}
run() {
time compile
prepare
time generate
time compare