Skip to content

Commit 70cdca6

Browse files
committed
main: Add support for running the tests with the JIT compiler enabled
1 parent 031b006 commit 70cdca6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def run_streaming_script(
7979
timeout: int,
8080
memory_limit: int,
8181
test_file_paths: list[Path],
82+
jit: bool,
8283
) -> subprocess.CompletedProcess:
8384
def limit_memory():
8485
if platform.system() != "Darwin":
@@ -104,6 +105,7 @@ def limit_memory():
104105
text=True,
105106
preexec_fn=limit_memory,
106107
errors="ignore", # strip invalid utf8 code points instead of throwing (to allow for invalid utf-8 tests)
108+
env=({"LIBJS_JIT": "1"} if jit else dict()),
107109
)
108110

109111

@@ -116,6 +118,7 @@ def run_tests(
116118
memory_limit: int,
117119
on_progress_change: Callable[[int, dict[str, int]], None] | None,
118120
forward_stderr: Callable[[str], None] | None,
121+
jit: bool,
119122
) -> list[TestRun]:
120123
current_test = 0
121124
results = []
@@ -148,6 +151,7 @@ def add_result(
148151
timeout,
149152
memory_limit,
150153
test_file_paths[current_test : current_test + BATCH_SIZE],
154+
jit,
151155
)
152156
except subprocess.CalledProcessError as e:
153157
process_failed = True
@@ -259,6 +263,7 @@ def __init__(
259263
extra_runner_options: list[str] | None = None,
260264
forward_stderr: bool = False,
261265
summary: bool = False,
266+
jit: bool = False,
262267
) -> None:
263268
self.libjs_test262_runner = libjs_test262_runner
264269
self.test262_root = test262_root
@@ -277,6 +282,7 @@ def __init__(
277282
self.extra_runner_options = extra_runner_options or []
278283
self.update_function: Callable[[int], None] | None = None
279284
self.print_output: Callable[[Optional[Any]], Any] = print
285+
self.jit = jit
280286

281287
self.forward_stderr_function: Callable[[str], None] | None
282288
if forward_stderr:
@@ -399,6 +405,7 @@ def process_list(self, files: list[Path]) -> list[TestRun]:
399405
memory_limit=self.memory_limit,
400406
on_progress_change=self.update_function,
401407
forward_stderr=self.forward_stderr_function,
408+
jit=self.jit,
402409
)
403410
except Exception as e:
404411
return [
@@ -499,6 +506,11 @@ def main() -> None:
499506
description="Run the test262 ECMAScript test suite with SerenityOS's LibJS",
500507
epilog=", ".join(f"{EMOJIS[result]} = {result.value}" for result in TestResult),
501508
)
509+
parser.add_argument(
510+
"--jit",
511+
action="store_true",
512+
help="Enable JIT compilation mode",
513+
)
502514
parser.add_argument(
503515
"-j",
504516
"--libjs-test262-runner",
@@ -611,6 +623,7 @@ def main() -> None:
611623
extra_runner_options,
612624
args.forward_stderr,
613625
args.summary,
626+
args.jit,
614627
)
615628
runner.find_tests(args.pattern, args.ignore)
616629
runner.run()

run_all_and_update_results.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def main() -> None:
8989
metavar="PATH",
9090
help="output the per-file result to this file",
9191
)
92+
parser.add_argument(
93+
"--jit",
94+
action="store_true",
95+
help="Enable JIT compilation mode",
96+
)
9297
args = parser.parse_args()
9398

9499
libjs_test262 = Path(__file__).parent
@@ -152,6 +157,7 @@ def main() -> None:
152157
f"--libjs-test262-runner {libjs_test262_runner} "
153158
f"--test262 {test262} "
154159
"--silent --summary --json "
160+
+ ("" if args.jit else "--jit ")
155161
+ (
156162
""
157163
if args.per_file_output is None

0 commit comments

Comments
 (0)