Skip to content

Commit 4ff9ee1

Browse files
davidotlinusg
authored andcommitted
main.py: Add --debug option which enabled debug logging
1 parent 8cf3a10 commit 4ff9ee1

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ optional arguments:
6767
--ignore IGNORE ignore any tests matching the glob
6868
--forward-stderr forward all stderr output to the stderr of the script
6969
--summary only show the top level results
70+
--debug enable debug logging of the runner
7071
```
7172

7273
## Current status

main.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def run_streaming_script(
7575
libjs_test262_runner: Path,
7676
test262_root: Path,
7777
use_bytecode: bool,
78-
parse_only: bool,
78+
extra_runner_options: list[str],
7979
timeout: int,
8080
memory_limit: int,
8181
test_file_paths: list[Path],
@@ -88,7 +88,7 @@ def limit_memory():
8888
command = [
8989
str(libjs_test262_runner),
9090
*(["-b"] if use_bytecode else []),
91-
*(["--parse-only"] if parse_only else []),
91+
*extra_runner_options,
9292
"--harness-location",
9393
str((test262_root / "harness").resolve()),
9494
"-t",
@@ -112,7 +112,7 @@ def run_tests(
112112
test262_root: Path,
113113
test_file_paths: list[Path],
114114
use_bytecode: bool,
115-
parse_only: bool,
115+
extra_runner_options: list[str],
116116
timeout: int,
117117
memory_limit: int,
118118
on_progress_change: Callable[[int, dict[str, int]], None] | None,
@@ -147,7 +147,7 @@ def add_result(
147147
libjs_test262_runner,
148148
test262_root,
149149
use_bytecode,
150-
parse_only,
150+
extra_runner_options,
151151
timeout,
152152
memory_limit,
153153
test_file_paths[current_test : current_test + BATCH_SIZE],
@@ -229,7 +229,7 @@ def add_result(
229229
current_test += 1
230230
elif forward_stderr is not None and process_result.stderr.strip() != "":
231231
forward_stderr(
232-
"Process did not fail but still there is stderr output:\n\n"
232+
"Process did not fail but still there is stderr output:\n"
233233
+ process_result.stderr
234234
)
235235

@@ -256,7 +256,7 @@ def __init__(
256256
use_bytecode: bool = False,
257257
track_per_file: bool = False,
258258
fail_only: bool = False,
259-
parse_only: bool = False,
259+
extra_runner_options: list[str] | None = None,
260260
forward_stderr: bool = False,
261261
summary: bool = False,
262262
) -> None:
@@ -275,7 +275,7 @@ def __init__(
275275
self.file_result_map: dict[str, str] = {}
276276
self.total_count = 0
277277
self.duration = datetime.timedelta()
278-
self.parse_only = parse_only
278+
self.extra_runner_options = extra_runner_options or []
279279
self.update_function: Callable[[int], None] | None = None
280280
self.print_output: Callable[[Optional[Any]], Any] = print
281281

@@ -396,7 +396,7 @@ def process_list(self, files: list[Path]) -> list[TestRun]:
396396
self.test262_root,
397397
files,
398398
use_bytecode=self.use_bytecode,
399-
parse_only=self.parse_only,
399+
extra_runner_options=self.extra_runner_options,
400400
timeout=self.timeout,
401401
memory_limit=self.memory_limit,
402402
on_progress_change=self.update_function,
@@ -590,9 +590,22 @@ def main() -> None:
590590
action="store_true",
591591
help="only show the top level results",
592592
)
593+
parser.add_argument(
594+
"--debug",
595+
action="store_true",
596+
help="enable debug logging of the runner",
597+
)
593598

594599
args = parser.parse_args()
595600

601+
extra_runner_options = []
602+
if args.parse_only:
603+
extra_runner_options.append("--parse-only")
604+
if args.debug:
605+
extra_runner_options.append("--debug")
606+
# We have to enable forward_stderr else the logs won't show up
607+
args.forward_stderr = True
608+
596609
runner = Runner(
597610
Path(args.libjs_test262_runner).resolve(),
598611
Path(args.test262_root).resolve(),
@@ -604,7 +617,7 @@ def main() -> None:
604617
args.use_bytecode,
605618
args.per_file is not None,
606619
args.fail_only,
607-
args.parse_only,
620+
extra_runner_options,
608621
args.forward_stderr,
609622
args.summary,
610623
)

0 commit comments

Comments
 (0)