Commit 9104072b authored by Tom Niget's avatar Tom Niget

Add extension support to test runner

parent c375d2bb
ALT_RUNNER='(clang++-16 -O3 -Wno-deprecated-declarations -Wno-return-type -Wno-unused-result -std=c++20 $(python3 __main__.py --cpp-flags) -o {name_bin} {name_cpp_posix} || exit 2) && ({run_file} || exit 0) && ({name_bin} || exit 3)' ALT_RUNNER='(clang++-16 -O3 -Wno-deprecated-declarations -Wno-return-type -Wno-unused-result -std=c++20 $(python3 __main__.py --cpp-flags) -o {name_bin} {name_cpp_posix} || exit 2) && ({run_file} || exit 0) && ({test_exec} || exit 3)'
\ No newline at end of file # don't use Windows SSH client
\ No newline at end of file
...@@ -66,7 +66,7 @@ def run_test(path, quiet=True): ...@@ -66,7 +66,7 @@ def run_test(path, quiet=True):
if quiet: if quiet:
sys.stdout = open(path.with_suffix(".out"), 'w') sys.stdout = open(path.with_suffix(".out"), 'w')
sys.stderr = open(path.with_suffix(".err"), 'w') sys.stderr = open(path.with_suffix(".err"), 'w')
print(path.name) print("** Running", path)
if path.name.startswith('_'): if path.name.startswith('_'):
print("Skipping") print("Skipping")
return TestStatus.SKIPPED return TestStatus.SKIPPED
...@@ -84,15 +84,20 @@ def run_test(path, quiet=True): ...@@ -84,15 +84,20 @@ def run_test(path, quiet=True):
name_cpp = path.with_suffix('.cpp') name_cpp = path.with_suffix('.cpp')
with open(name_cpp, "w", encoding="utf-8") as fcpp: with open(name_cpp, "w", encoding="utf-8") as fcpp:
fcpp.write(res) fcpp.write(res)
print(".cpp generated")
if args.compile: if args.compile:
return TestStatus.SUCCESS return TestStatus.SUCCESS
execute_str = "true" if (execute and not args.generate) else "false" execute_str = "true" if (execute and not args.generate) else "false"
name_bin = path.with_suffix('').as_posix() name_bin = path.with_suffix("").as_posix() + ("$(python3-config --extension-suffix)" if extension else ".exe")
if exec_cmd(f'bash -c "export PYTHONPATH=stdlib; if {execute_str}; then python3 ./{path.as_posix()}; fi"') != 0: if exec_cmd(f'bash -c "export PYTHONPATH=stdlib; if {execute_str}; then python3 ./{path.as_posix()}; fi"') != 0:
return TestStatus.PYTHON_ERROR return TestStatus.PYTHON_ERROR
if compile and (alt := environ.get("ALT_RUNNER")): if compile and (alt := environ.get("ALT_RUNNER")):
if (code := exec_cmd(alt.format(name_bin=name_bin, name_cpp_posix=name_cpp.as_posix(), run_file=execute_str))) != 0: if (code := exec_cmd(alt.format(
name_bin=name_bin,
name_cpp_posix=name_cpp.as_posix(),
run_file=execute_str,
test_exec=f"python3 {path.with_suffix('.post.py').as_posix()}" if extension else name_bin,
bonus_flags="-e" if extension else ""
))) != 0:
return TestStatus(code) return TestStatus(code)
else: else:
print("no ALT_RUNNER") print("no ALT_RUNNER")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment