Skip to content

Commit 7902cfc

Browse files
committed
Give wptrunner a distinct exit code for CRITICAL errors
Previously, when running tests without --stability, wptrunner would exit with 1 if there were unexpected results or if there was a critical log message. With --stability, wptrunner would exit with either 1 or 2 for stability failures, and 1 if the stability check succeeded but there were critical log messages. In either case, wpt run would then simplify this to always exiting with 0 or 1. We now reserve exit codes above 64 for wptrunner's own usage, and exit with 64 if there is a critical log message. This now takes priority over the original exit code. We also now allow wpt run to exit with the exit code that wptrunner returns.
1 parent bc43c24 commit 7902cfc

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

tools/wpt/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ def run(venv, **kwargs):
10101010
setup_cls, wptrunner_kwargs = setup_wptrunner(venv, **kwargs)
10111011

10121012
try:
1013-
rv = run_single(venv, **wptrunner_kwargs) > 0
1013+
rv = run_single(venv, **wptrunner_kwargs)
10141014
finally:
10151015
setup_cls.teardown()
10161016

tools/wptrunner/wptrunner/wptrunner.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,14 @@ def check_stability(**kwargs):
568568
**kwargs)
569569

570570

571-
def start(**kwargs):
571+
def start(**kwargs: Any) -> int:
572572
assert logger is not None
573573

574574
logged_critical = wptlogging.LoggedAboveLevelHandler("CRITICAL")
575575
handler = handlers.LogLevelFilter(logged_critical, "CRITICAL")
576576
logger.add_handler(handler)
577577

578-
rv = False
578+
rv = 0
579579
try:
580580
if kwargs["list_test_groups"]:
581581
list_test_groups(**kwargs)
@@ -586,12 +586,19 @@ def start(**kwargs):
586586
elif kwargs["list_tests_json"]:
587587
list_tests_json(**kwargs)
588588
elif kwargs["verify"] or kwargs["stability"]:
589-
rv = check_stability(**kwargs) or logged_critical.has_log
589+
rv = check_stability(**kwargs)
590590
else:
591-
rv = not run_tests(**kwargs)[0] or logged_critical.has_log
591+
rv = not run_tests(**kwargs)[0]
592592
finally:
593593
logger.shutdown()
594594
logger.remove_handler(handler)
595+
596+
# Reserve everything above 64 for our global usage.
597+
assert 0 <= rv < 64, "Exit codes above 64 are reserved"
598+
if logged_critical.has_log:
599+
print("Did log critical")
600+
rv = 64
601+
595602
return rv
596603

597604

0 commit comments

Comments
 (0)