From 5f2645c6af74cfe4b33a65e11c017bee7133a4bc Mon Sep 17 00:00:00 2001 From: savalet Date: Sat, 3 May 2025 22:42:48 +0200 Subject: [PATCH] Add tester in makefile --- Makefile | 3 +-- validator.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 410cada..d01de32 100644 --- a/Makefile +++ b/Makefile @@ -81,8 +81,7 @@ all: $(NAME_release) .PHONY: tests_run tests_run: $(NAME_test) - - find fixtures -name "*.sh" | xargs -i \ - sh -c 'cat {} | env -i PATH="$(dir $(shell which ls))" ./$^' + @ - python3 validator.py ./$(NAME_test) .PHONY: cov cov: tests_run diff --git a/validator.py b/validator.py index c4cb129..ef40071 100755 --- a/validator.py +++ b/validator.py @@ -66,7 +66,7 @@ class Test: key: str, name: str, cmds: list[str], - depends_on: tuple[str, ...] = () + depends_on: tuple[str, ...] = (), ): self.key = key self.name = name @@ -74,8 +74,8 @@ class Test: self.depends_on = depends_on self.has_run = False - def _run_each_cmd(self, cmd: str): - result_42sh = run_shell(["./42sh"], cmd) + def _run_each_cmd(self, cmd: str, tested_bin): + result_42sh = run_shell([tested_bin], cmd) result_tcsh = run_shell(["tcsh"], cmd) if result_42sh.exit_code == 84 and result_tcsh.exit_code != 0: @@ -88,7 +88,7 @@ class Test: print("\033[31m.\033[0m", end='') # ]] return cmd, result_42sh, result_tcsh - def run(self, test_map) -> bool: + def run(self, test_map, tested_bin) -> bool: if self.has_run: return True @@ -104,7 +104,7 @@ class Test: continue if not dep.has_run: - success &= dep.run(test_map) + success &= dep.run(test_map, tested_bin) if not success: return False @@ -112,7 +112,7 @@ class Test: failures = [] for cmd in self.cmds: - if (failure := self._run_each_cmd(cmd)) is not None: + if (failure := self._run_each_cmd(cmd, tested_bin)) is not None: failures.append(failure) if not failures: print(" \033[32mOK\033[0m") # ]] @@ -130,7 +130,10 @@ def main(): success = True for test in TESTS: - success &= test.run(test_map=test_map) + success &= test.run( + test_map=test_map, + tested_bin=sys.argv[1] if len(sys.argv) > 1 else "./42sh" + ) return not success