From b9450da442aa495943ec84da3ef8d09a46bd99c7 Mon Sep 17 00:00:00 2001 From: drunkendog Date: Tue, 12 Sep 2023 16:15:52 +0100 Subject: [PATCH] Fix windows support, add report at end of tests --- run-tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run-tests.py b/run-tests.py index 13ede57..f6000e6 100644 --- a/run-tests.py +++ b/run-tests.py @@ -21,11 +21,16 @@ for file_name in glob.glob("*.c", recursive=False): should_continue = input(f"{file_name}; run (y/N)? ").lower() if should_continue != "y": continue - subprocess.run(["gcc", "-std=c11", "-Wall", "-g", file_name], check=True) + subprocess.run(["gcc", "-o", "a.out", "-std=c11", "-Wall", "-g", file_name], check=True) with open(next(x for x in file_list if file_name.rstrip(".c") in x)) as f: to_run = f.read().split("\n\n") + total_tests, passed_tests = 0, 0 for x in to_run: x_split = x.split("\n") return_data = subprocess.run(["./a.out"], input=x_split[0].rstrip().encode(), capture_output=True).stdout.decode().rstrip() - print(f"\u001b[{31 + int(return_data == x_split[1].rstrip())}m{return_data}\u001b[0m", x_split[1]) + test_passed_int = int(return_data == x_split[1].rstrip()) + total_tests += 1 + passed_tests += test_passed_int + print(f"\u001b[{31 + test_passed_int}m{return_data}\u001b[0m", x_split[1]) + print(f"\u001b[32m{passed_tests} tests passed\u001b[0m, \u001b[{31 - 31*int(total_tests == passed_tests)}m{total_tests - passed_tests} tests failed\u001b[0m") os.remove("a.out")