scripts: test.py/bench.py: Added support for multiple header files

Like test.py --gdb-script, being able to specify multiple header files
seems useful and is easy enough to add.

---

Note that the default is only used if no other header files are
specified, so this _replaces_ the default header file:

  $ ./scripts/test.py --include=my_header.h

If you don't want to replace the default header file, you currently need
to specify it explicitly:

  $ ./scripts/test.py \
        --include=runners/test_runner.h \
        --include=my_header.h
This commit is contained in:
Christopher Haster
2025-07-04 12:49:00 -05:00
parent 0b804c092b
commit 0c19a68536
2 changed files with 10 additions and 10 deletions

View File

@ -38,7 +38,7 @@ except ModuleNotFoundError:
RUNNER_PATH = ['./runners/test_runner']
HEADER_PATH = 'runners/test_runner.h'
HEADER_PATHS = ['./runners/test_runner.h']
GDB_PATH = ['gdb']
GDB_SCRIPTS = ['./scripts/dbg.gdb.py']
@ -395,7 +395,8 @@ def compile(test_paths, **args):
f.writeln()
# include test_runner.h in every generated file
f.writeln("#include \"%s\"" % args['include'])
for header in (args.get('include') or HEADER_PATHS):
f.writeln("#include \"%s\"" % header)
f.writeln()
# write out generated functions, this can end up in different
@ -1800,9 +1801,8 @@ if __name__ == "__main__":
help="Source file to compile, possibly injecting internal tests.")
comp_parser.add_argument(
'--include',
default=HEADER_PATH,
help="Inject this header file into every compiled test file. "
"Defaults to %r." % HEADER_PATH)
help="Inject these header files into every compiled test file. "
"Defaults to %r." % HEADER_PATHS)
comp_parser.add_argument(
'-o', '--output',
help="Output file.")