From c46423265f12adf1e2d172d2ca95736d3bf43b77 Mon Sep 17 00:00:00 2001 From: ahmedsamyh Date: Mon, 3 Mar 2025 17:45:13 +0500 Subject: [PATCH] [testing] Prefix expected outputs with . (make it hidden) --- test.py | 13 ++++++++++--- ...de.expected => .identifiers.build.code.expected} | 0 ...err.expected => .identifiers.build.err.expected} | 0 ...out.expected => .identifiers.build.out.expected} | 0 ...ers.code.expected => .identifiers.code.expected} | 0 ...fiers.err.expected => .identifiers.err.expected} | 0 ...fiers.out.expected => .identifiers.out.expected} | 0 ...code.expected => .operators.build.code.expected} | 0 ...d.err.expected => .operators.build.err.expected} | 0 ...d.out.expected => .operators.build.out.expected} | 0 ...ators.code.expected => .operators.code.expected} | 0 ...erators.err.expected => .operators.err.expected} | 0 ...erators.out.expected => .operators.out.expected} | 0 ...d.code.expected => .strings.build.code.expected} | 0 ...ild.err.expected => .strings.build.err.expected} | 0 ...ild.out.expected => .strings.build.out.expected} | 0 ...strings.code.expected => .strings.code.expected} | 0 .../{strings.err.expected => .strings.err.expected} | 0 .../{strings.out.expected => .strings.out.expected} | 0 19 files changed, 10 insertions(+), 3 deletions(-) rename tests/{identifiers.build.code.expected => .identifiers.build.code.expected} (100%) rename tests/{identifiers.build.err.expected => .identifiers.build.err.expected} (100%) rename tests/{identifiers.build.out.expected => .identifiers.build.out.expected} (100%) rename tests/{identifiers.code.expected => .identifiers.code.expected} (100%) rename tests/{identifiers.err.expected => .identifiers.err.expected} (100%) rename tests/{identifiers.out.expected => .identifiers.out.expected} (100%) rename tests/{operators.build.code.expected => .operators.build.code.expected} (100%) rename tests/{operators.build.err.expected => .operators.build.err.expected} (100%) rename tests/{operators.build.out.expected => .operators.build.out.expected} (100%) rename tests/{operators.code.expected => .operators.code.expected} (100%) rename tests/{operators.err.expected => .operators.err.expected} (100%) rename tests/{operators.out.expected => .operators.out.expected} (100%) rename tests/{strings.build.code.expected => .strings.build.code.expected} (100%) rename tests/{strings.build.err.expected => .strings.build.err.expected} (100%) rename tests/{strings.build.out.expected => .strings.build.out.expected} (100%) rename tests/{strings.code.expected => .strings.code.expected} (100%) rename tests/{strings.err.expected => .strings.err.expected} (100%) rename tests/{strings.out.expected => .strings.out.expected} (100%) diff --git a/test.py b/test.py index 87642fd..17b5faf 100755 --- a/test.py +++ b/test.py @@ -21,7 +21,7 @@ class Test: self.name = name def read_or_create_expected_file(name: str) -> str: - f = f"{self.name}.{name}.expected" + f = self.get_expected_filename(name) if not os.path.exists(f): with open(f, "w") as file: print(f"[INFO] Created empty {self.name}.{name}.expected") @@ -50,7 +50,7 @@ class Test: # if self.expected_stderr: print(f"{self.name}.err.expected: {self.expected_stderr}") def save_expected(self): def write_expected(name: str, content: str): - f = f"{self.name}.{name}.expected" + f = self.get_expected_filename(name) with open(f, "w") as file: file.write(content) @@ -62,6 +62,12 @@ class Test: write_expected("build.err", self.build_expected_stderr) write_expected("build.code", str(self.build_expected_returncode)) + def get_expected_filename(self, name): + if name not in [ "out", "err", "code", "build.out", "build.err", "build.code" ]: + raise Exception("Please pass a valid name") + + return f".{self.name}.{name}.expected" + def usage(program: str): print(f"Usage: {program} [flags]") @@ -188,6 +194,7 @@ def main(): print(f"Build {passing_tests_count}/{total_tests_count} tests") elif subcmd == "run": + assert False, "'run' Subcommand is not fully tested!" print(f'----- [RUN] -----') for test_name in tests: print(f'+ Running {test_name} [{current_test_id+1}/{total_tests_count}]...') @@ -219,6 +226,7 @@ def main(): print(f"PASSED {passing_tests_count}/{total_tests_count}") elif subcmd == "record": + assert False, "'record' Subcommand is not fully tested!" print(f'----- [RECORD] -----') for test_name in tests: print(f"+ Recording expected behaviour for '{test_name}'...") @@ -259,7 +267,6 @@ def main(): ans = input(prompt_msg) if ans.lower() == "y": - tests[test_name].build_expected_stdout = res.stdout tests[test_name].build_expected_stderr = res.stderr tests[test_name].build_expected_returncode = res.returncode diff --git a/tests/identifiers.build.code.expected b/tests/.identifiers.build.code.expected similarity index 100% rename from tests/identifiers.build.code.expected rename to tests/.identifiers.build.code.expected diff --git a/tests/identifiers.build.err.expected b/tests/.identifiers.build.err.expected similarity index 100% rename from tests/identifiers.build.err.expected rename to tests/.identifiers.build.err.expected diff --git a/tests/identifiers.build.out.expected b/tests/.identifiers.build.out.expected similarity index 100% rename from tests/identifiers.build.out.expected rename to tests/.identifiers.build.out.expected diff --git a/tests/identifiers.code.expected b/tests/.identifiers.code.expected similarity index 100% rename from tests/identifiers.code.expected rename to tests/.identifiers.code.expected diff --git a/tests/identifiers.err.expected b/tests/.identifiers.err.expected similarity index 100% rename from tests/identifiers.err.expected rename to tests/.identifiers.err.expected diff --git a/tests/identifiers.out.expected b/tests/.identifiers.out.expected similarity index 100% rename from tests/identifiers.out.expected rename to tests/.identifiers.out.expected diff --git a/tests/operators.build.code.expected b/tests/.operators.build.code.expected similarity index 100% rename from tests/operators.build.code.expected rename to tests/.operators.build.code.expected diff --git a/tests/operators.build.err.expected b/tests/.operators.build.err.expected similarity index 100% rename from tests/operators.build.err.expected rename to tests/.operators.build.err.expected diff --git a/tests/operators.build.out.expected b/tests/.operators.build.out.expected similarity index 100% rename from tests/operators.build.out.expected rename to tests/.operators.build.out.expected diff --git a/tests/operators.code.expected b/tests/.operators.code.expected similarity index 100% rename from tests/operators.code.expected rename to tests/.operators.code.expected diff --git a/tests/operators.err.expected b/tests/.operators.err.expected similarity index 100% rename from tests/operators.err.expected rename to tests/.operators.err.expected diff --git a/tests/operators.out.expected b/tests/.operators.out.expected similarity index 100% rename from tests/operators.out.expected rename to tests/.operators.out.expected diff --git a/tests/strings.build.code.expected b/tests/.strings.build.code.expected similarity index 100% rename from tests/strings.build.code.expected rename to tests/.strings.build.code.expected diff --git a/tests/strings.build.err.expected b/tests/.strings.build.err.expected similarity index 100% rename from tests/strings.build.err.expected rename to tests/.strings.build.err.expected diff --git a/tests/strings.build.out.expected b/tests/.strings.build.out.expected similarity index 100% rename from tests/strings.build.out.expected rename to tests/.strings.build.out.expected diff --git a/tests/strings.code.expected b/tests/.strings.code.expected similarity index 100% rename from tests/strings.code.expected rename to tests/.strings.code.expected diff --git a/tests/strings.err.expected b/tests/.strings.err.expected similarity index 100% rename from tests/strings.err.expected rename to tests/.strings.err.expected diff --git a/tests/strings.out.expected b/tests/.strings.out.expected similarity index 100% rename from tests/strings.out.expected rename to tests/.strings.out.expected -- 2.39.5