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)'
\ No newline at end of file
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)'
# don't use Windows SSH client
\ No newline at end of file
......@@ -66,7 +66,7 @@ def run_test(path, quiet=True):
if quiet:
sys.stdout = open(path.with_suffix(".out"), 'w')
sys.stderr = open(path.with_suffix(".err"), 'w')
print(path.name)
print("** Running", path)
if path.name.startswith('_'):
print("Skipping")
return TestStatus.SKIPPED
......@@ -84,15 +84,20 @@ def run_test(path, quiet=True):
name_cpp = path.with_suffix('.cpp')
with open(name_cpp, "w", encoding="utf-8") as fcpp:
fcpp.write(res)
print(".cpp generated")
if args.compile:
return TestStatus.SUCCESS
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:
return TestStatus.PYTHON_ERROR
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)
else:
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