From 3832d6553703487745b50d98d1516e2fd3beaaa8 Mon Sep 17 00:00:00 2001 From: zjx Date: Thu, 19 Mar 2026 19:24:54 +0800 Subject: [PATCH] feat(antlr4),test(run_tests.py) --- run_tests.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 run_tests.py 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