Tests/LibJS: Add test-js-bytecode --rebaseline

This commit is contained in:
Andreas Kling 2026-02-17 16:46:02 +01:00 committed by Andreas Kling
parent 36acd1cf3d
commit 06f7abe00f

View file

@ -53,6 +53,9 @@ def diff(a: str, a_file: Path, b: str, b_file: Path) -> None:
print(f"{color_prefix}{line}\x1b[0m")
REBASELINE = False
def test(file: Path) -> bool:
args = [
str(BUILD_DIR / "bin/js"),
@ -72,10 +75,15 @@ def test(file: Path) -> bool:
stdout = strip_color(stdout)
output_file = BYTECODE_TEST_DIR / "output" / file.with_suffix(".txt")
expected_file = BYTECODE_TEST_DIR / "expected" / file.with_suffix(".txt")
output_file = BYTECODE_TEST_DIR / "output" / file.with_suffix(".txt")
output_file.write_text(stdout, encoding="utf8")
if REBASELINE:
expected_file.write_text(stdout + "\n", encoding="utf8")
return False
expected = expected_file.read_text(encoding="utf8").strip()
if stdout != expected:
@ -91,10 +99,14 @@ def test(file: Path) -> bool:
def main() -> int:
setup()
global REBASELINE
parser = ArgumentParser()
parser.add_argument("-j", "--jobs", type=int)
parser.add_argument("--rebaseline", action="store_true")
args = parser.parse_args()
REBASELINE = args.rebaseline
input_dir = BYTECODE_TEST_DIR / "input"
failed = 0