Skip to content

Commit 637c5ec

Browse files
committed
Bug 1878955 [wpt PR 44424] - [wptrunner] Plumb expectations wpttest.{Test -> (Subtest)Result}, a=testonly
Automatic update from web-platform-tests [wptrunner] Plumb expectations `wpttest.{Test -> (Subtest)Result}` (#44424) This allows vendors to override expectations at runtime via browser-specific result converters. Instead of constructing `(Subtest)Result`s directly, executors should use the newly introduced `Test.make_{subtest_,}result()`, which have the same signatures but default to passing through the testloader-read expectations. This is a pure refactor; no functional changes intended. Successor to: web-platform-tests/wpt#44134 (comment) -- wpt-commits: a68f313a50899795e1e6660b7398544d340f1652 wpt-pr: 44424 UltraBlame original commit: b53534ad1edfde1911bd2d17ce4526db588f2942
1 parent 5b023ac commit 637c5ec

11 files changed

+155
-175
lines changed

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/base.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def __call__(self, test, result, extra=None):
9090
"""Convert a JSON result into a (TestResult, [SubtestResult]) tuple"""
9191
result_url, status, message, stack, subtest_results = result
9292
assert result_url == test.url, (f"Got results from {result_url}, expected {test.url}")
93-
harness_result = test.result_cls(self.harness_codes[status], message, extra=extra, stack=stack)
93+
harness_result = test.make_result(self.harness_codes[status], message, extra=extra, stack=stack)
9494
return (harness_result,
95-
[test.subtest_result_cls(st_name, self.test_codes[st_status], st_message, st_stack)
95+
[test.make_subtest_result(st_name, self.test_codes[st_status], st_message, st_stack)
9696
for st_name, st_status, st_message, st_stack in subtest_results])
9797

9898

@@ -152,7 +152,7 @@ def get_pages(ranges_value, total_pages):
152152
def reftest_result_converter(self, test, result):
153153
extra = result.get("extra", {})
154154
_ensure_hash_in_reftest_screenshots(extra)
155-
return (test.result_cls(
155+
return (test.make_result(
156156
result["status"],
157157
result["message"],
158158
extra=extra,
@@ -165,14 +165,14 @@ def pytest_result_converter(self, test, data):
165165
if subtest_data is None:
166166
subtest_data = []
167167

168-
harness_result = test.result_cls(*harness_data)
169-
subtest_results = [test.subtest_result_cls(*item) for item in subtest_data]
168+
harness_result = test.make_result(*harness_data)
169+
subtest_results = [test.make_subtest_result(*item) for item in subtest_data]
170170

171171
return (harness_result, subtest_results)
172172

173173

174174
def crashtest_result_converter(self, test, result):
175-
return test.result_cls(**result), []
175+
return test.make_result(**result), []
176176

177177

178178
class ExecutorException(Exception):
@@ -352,7 +352,7 @@ def result_from_exception(self, test, e, exception_string):
352352
if message:
353353
message += "\n"
354354
message += exception_string
355-
return test.result_cls(status, message), []
355+
return test.make_result(status, message), []
356356

357357
def wait(self):
358358
return self.protocol.base.wait()
@@ -648,7 +648,7 @@ def do_test(self, test):
648648
if success:
649649
return self.convert_result(test, data)
650650

651-
return (test.result_cls(*data), [])
651+
return (test.make_result(*data), [])
652652

653653
def do_wdspec(self, path, timeout):
654654
session_config = {"host": self.browser.host,

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorchrome.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def convert_from_crashtest_result(test, result):
4646
status = result["status"]
4747
if status == "PASS":
4848
status = "OK"
49-
harness_result = test.result_cls(status, result["message"])
49+
harness_result = test.make_result(status, result["message"])
5050

5151
return harness_result, []
5252

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorcontentshell.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ def _convert_exception(test, exception, errors):
213213
"""Converts our TimeoutError and CrashError exceptions into test results.
214214
"""
215215
if isinstance(exception, TimeoutError):
216-
return (test.result_cls("EXTERNAL-TIMEOUT", errors), [])
216+
return (test.make_result("EXTERNAL-TIMEOUT", errors), [])
217217
if isinstance(exception, CrashError):
218-
return (test.result_cls("CRASH", errors), [])
218+
return (test.make_result("CRASH", errors), [])
219219
if isinstance(exception, LeakError):
220220

221221

222222

223-
return (test.result_cls("INTERNAL-ERROR", errors), [])
223+
return (test.make_result("INTERNAL-ERROR", errors), [])
224224
raise exception
225225

226226

@@ -312,7 +312,7 @@ def do_test(self, test):
312312
timeout_for_test(self, test))
313313
errors = self.protocol.content_shell_errors.read_errors()
314314
if not text:
315-
return (test.result_cls("ERROR", errors), [])
315+
return (test.make_result("ERROR", errors), [])
316316

317317
result_url, status, message, stack, subtest_results = json.loads(text)
318318
if result_url != test.url:

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ def do_test(self, test):
979979
if success:
980980
return self.convert_result(test, data, extra=extra)
981981

982-
return (test.result_cls(extra=extra, *data), [])
982+
return (test.make_result(extra=extra, *data), [])
983983

984984
def do_testharness(self, protocol, url, timeout):
985985
parent_window = protocol.testharness.close_old_windows(self.last_environment["protocol"])
@@ -1277,7 +1277,7 @@ def do_test(self, test):
12771277
if success:
12781278
return self.convert_result(test, data)
12791279

1280-
return (test.result_cls(extra=extra, *data), [])
1280+
return (test.make_result(extra=extra, *data), [])
12811281

12821282
def do_crashtest(self, protocol, url, timeout):
12831283
if self.protocol.coverage.is_enabled:

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorselenium.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def do_test(self, test):
369369
if success:
370370
return self.convert_result(test, data)
371371

372-
return (test.result_cls(*data), [])
372+
return (test.make_result(*data), [])
373373

374374
def do_testharness(self, protocol, url, timeout):
375375
format_map = {"url": strip_server(url)}

0 commit comments

Comments
 (0)