diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 0000000..0fc909c --- /dev/null +++ b/run_tests.py @@ -0,0 +1,39 @@ +import os +import subprocess + +COMPILER = "./build/bin/compiler" +TEST_DIR = "./test/test_case/functional" + +pass_cnt = 0 +fail_cnt = 0 + +print("===== SysY Batch Test Start =====") + +for file in os.listdir(TEST_DIR): + if not file.endswith(".sy"): + continue + + path = os.path.join(TEST_DIR, file) + print(f"[TEST] {file} ... ", end="") + + result = subprocess.run( + [COMPILER, "--emit-parse-tree", path], + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE + ) + + if result.returncode == 0: + print("PASS") + pass_cnt += 1 + else: + print("FAIL") + fail_cnt += 1 + print("---- Error ----") + print(result.stderr.decode()) + print("---------------") + +print("===============================") +print(f"Total: {pass_cnt + fail_cnt}") +print(f"PASS : {pass_cnt}") +print(f"FAIL : {fail_cnt}") +print("===============================") \ No newline at end of file