From 181f97879dfc17b31acc608c6b996922035d997b Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Sat, 2 Aug 2025 15:04:17 +0200 Subject: [PATCH] wpt: Ensure that faulty JSON testharness output does not crash the Python test harness (#38420) When a testharness test also prints debugging output, sometimes the output can be mixed with the JSON output printed via an alert. This causes a JSON decoding error in the output. Instead of crashing the harness and printing many lines of Python stack trace output, print a nice error. This makes the test output easier to read. Testing: This is a change to the test harness itself, so no tests necessary. Signed-off-by: Martin Robinson --- tests/wpt/meta/MANIFEST.json | 2 +- .../tools/wptrunner/wptrunner/executors/executorservo.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 3dc39e93a10..06c1af4f347 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -521535,7 +521535,7 @@ [] ], "executorservo.py": [ - "7b0a64a60489f91fe2d2ec92c69118c0b5b1b8c0", + "d983cf048ed6dfe1c07fdcac4f3465f116a00c58", [] ], "executorservodriver.py": [ diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py index 7b0a64a6048..d983cf048ed 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py @@ -173,7 +173,10 @@ class ServoTestharnessExecutor(ServoExecutor): prefix = "ALERT: RESULT: " decoded_line = line.decode("utf8", "replace") if decoded_line.startswith(prefix): - self.result_data = json.loads(decoded_line[len(prefix):]) + try: + self.result_data = json.loads(decoded_line[len(prefix):]) + except json.JSONDecodeError as error: + self.logger.error(f"Could not process test output JSON: {error}") self.result_flag.set() else: ServoExecutor.on_output(self, line)