Tests/LibJS: Add test-js-bytecode --rebaseline
This commit is contained in:
parent
36acd1cf3d
commit
06f7abe00f
1 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue