From ff7225cb2bb70fa0d4ff4137aa768aa1492fa19a Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 25 Sep 2023 18:45:16 +0100 Subject: [PATCH 1/4] Update run-tests.py --- run-tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run-tests.py b/run-tests.py index 3ecb3c1..d9d47ed 100644 --- a/run-tests.py +++ b/run-tests.py @@ -4,6 +4,8 @@ import glob import subprocess import os import sys +import differ +import pprint # will break if there are namespace collisions @@ -27,12 +29,14 @@ for file_name in glob.glob("*.c", recursive=False): to_run = f.read().strip().split("\n\n") total_tests, passed_tests = 0, 0 for x in to_run: - x_split = x.rsplit("\n", 1) + x_split = x.split("\n", 1) return_data = subprocess.run(["./a.out"], input=x_split[0].rstrip().encode(), capture_output=True).stdout.decode().rstrip() test_passed_int = int(return_data == x_split[1].rstrip()) total_tests += 1 passed_tests += test_passed_int - print(f"({x_split[0]})", x_split[1], f"\u001b[{31 + test_passed_int}m{return_data}\u001b[0m") + print(f"\u001b[{31 + test_passed_int}m({x_split[0]})\u001b[0m") + if not passed_tests: + pprint.pprint(list(differ.Differ().compare(x_split[1].splitlines(), return_data.splitlines()))) 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") exit_code += total_tests - passed_tests os.remove("a.out") From a21d23b75bd9993a2c227fb6427fdecfa08fbf8b Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 25 Sep 2023 18:46:21 +0100 Subject: [PATCH 2/4] Fix typo --- run-tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.py b/run-tests.py index d9d47ed..4fde780 100644 --- a/run-tests.py +++ b/run-tests.py @@ -4,7 +4,7 @@ import glob import subprocess import os import sys -import differ +import difflib import pprint # will break if there are namespace collisions @@ -36,7 +36,7 @@ for file_name in glob.glob("*.c", recursive=False): passed_tests += test_passed_int print(f"\u001b[{31 + test_passed_int}m({x_split[0]})\u001b[0m") if not passed_tests: - pprint.pprint(list(differ.Differ().compare(x_split[1].splitlines(), return_data.splitlines()))) + pprint.pprint(list(difflib.Differ().compare(x_split[1].splitlines(), return_data.splitlines()))) 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") exit_code += total_tests - passed_tests os.remove("a.out") From c6f1b2446a304546f395616e0c1804066802e673 Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 25 Sep 2023 19:51:01 +0100 Subject: [PATCH 3/4] Update run-tests.py --- run-tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.py b/run-tests.py index 4fde780..c8c3052 100644 --- a/run-tests.py +++ b/run-tests.py @@ -35,7 +35,7 @@ for file_name in glob.glob("*.c", recursive=False): total_tests += 1 passed_tests += test_passed_int print(f"\u001b[{31 + test_passed_int}m({x_split[0]})\u001b[0m") - if not passed_tests: + if True: # not passed_tests: pprint.pprint(list(difflib.Differ().compare(x_split[1].splitlines(), return_data.splitlines()))) 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") exit_code += total_tests - passed_tests From cb4bdaec173dbafb02f762bb2a300b83bc2dc02c Mon Sep 17 00:00:00 2001 From: drunkendog Date: Mon, 25 Sep 2023 19:58:01 +0100 Subject: [PATCH 4/4] Replace pprint with print --- run-tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/run-tests.py b/run-tests.py index c8c3052..649b381 100644 --- a/run-tests.py +++ b/run-tests.py @@ -5,7 +5,6 @@ import subprocess import os import sys import difflib -import pprint # will break if there are namespace collisions @@ -35,8 +34,10 @@ for file_name in glob.glob("*.c", recursive=False): total_tests += 1 passed_tests += test_passed_int print(f"\u001b[{31 + test_passed_int}m({x_split[0]})\u001b[0m") - if True: # not passed_tests: - pprint.pprint(list(difflib.Differ().compare(x_split[1].splitlines(), return_data.splitlines()))) + if not passed_tests: + [print(x) for x in difflib.Differ().compare(x_split[1].splitlines(), return_data.splitlines())] + else: + [print(x) for x in return_data.splitlines()] 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") exit_code += total_tests - passed_tests os.remove("a.out")