Skip to content

Commit

Permalink
main: Add support for running the tests with the JIT compiler enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpfard committed Nov 5, 2023
1 parent 031b006 commit 70cdca6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def run_streaming_script(
timeout: int,
memory_limit: int,
test_file_paths: list[Path],
jit: bool,
) -> subprocess.CompletedProcess:
def limit_memory():
if platform.system() != "Darwin":
Expand All @@ -104,6 +105,7 @@ def limit_memory():
text=True,
preexec_fn=limit_memory,
errors="ignore", # strip invalid utf8 code points instead of throwing (to allow for invalid utf-8 tests)
env=({"LIBJS_JIT": "1"} if jit else dict()),
)


Expand All @@ -116,6 +118,7 @@ def run_tests(
memory_limit: int,
on_progress_change: Callable[[int, dict[str, int]], None] | None,
forward_stderr: Callable[[str], None] | None,
jit: bool,
) -> list[TestRun]:
current_test = 0
results = []
Expand Down Expand Up @@ -148,6 +151,7 @@ def add_result(
timeout,
memory_limit,
test_file_paths[current_test : current_test + BATCH_SIZE],
jit,
)
except subprocess.CalledProcessError as e:
process_failed = True
Expand Down Expand Up @@ -259,6 +263,7 @@ def __init__(
extra_runner_options: list[str] | None = None,
forward_stderr: bool = False,
summary: bool = False,
jit: bool = False,
) -> None:
self.libjs_test262_runner = libjs_test262_runner
self.test262_root = test262_root
Expand All @@ -277,6 +282,7 @@ def __init__(
self.extra_runner_options = extra_runner_options or []
self.update_function: Callable[[int], None] | None = None
self.print_output: Callable[[Optional[Any]], Any] = print
self.jit = jit

self.forward_stderr_function: Callable[[str], None] | None
if forward_stderr:
Expand Down Expand Up @@ -399,6 +405,7 @@ def process_list(self, files: list[Path]) -> list[TestRun]:
memory_limit=self.memory_limit,
on_progress_change=self.update_function,
forward_stderr=self.forward_stderr_function,
jit=self.jit,
)
except Exception as e:
return [
Expand Down Expand Up @@ -499,6 +506,11 @@ def main() -> None:
description="Run the test262 ECMAScript test suite with SerenityOS's LibJS",
epilog=", ".join(f"{EMOJIS[result]} = {result.value}" for result in TestResult),
)
parser.add_argument(
"--jit",
action="store_true",
help="Enable JIT compilation mode",
)
parser.add_argument(
"-j",
"--libjs-test262-runner",
Expand Down Expand Up @@ -611,6 +623,7 @@ def main() -> None:
extra_runner_options,
args.forward_stderr,
args.summary,
args.jit,
)
runner.find_tests(args.pattern, args.ignore)
runner.run()
Expand Down
6 changes: 6 additions & 0 deletions run_all_and_update_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def main() -> None:
metavar="PATH",
help="output the per-file result to this file",
)
parser.add_argument(
"--jit",
action="store_true",
help="Enable JIT compilation mode",
)
args = parser.parse_args()

libjs_test262 = Path(__file__).parent
Expand Down Expand Up @@ -152,6 +157,7 @@ def main() -> None:
f"--libjs-test262-runner {libjs_test262_runner} "
f"--test262 {test262} "
"--silent --summary --json "
+ ("" if args.jit else "--jit ")
+ (
""
if args.per_file_output is None
Expand Down

1 comment on commit 70cdca6

@BertalanD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :p

Please sign in to comment.