Skip to content

Commit 01a3115

Browse files
committed
override default testharnessreport
For simpler usage with Lightpanda WPT test runner, we override the default testharnessreport.
1 parent db497cd commit 01a3115

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

resources/testharnessreport.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
/* global add_completion_callback */
2-
/* global setup */
3-
41
/*
5-
* This file is intended for vendors to implement code needed to integrate
6-
* testharness.js tests with their own test systems.
7-
*
8-
* Typically test system integration will attach callbacks when each test has
9-
* run, using add_result_callback(callback(test)), or when the whole test file
10-
* has completed, using
11-
* add_completion_callback(callback(tests, harness_status)).
12-
*
13-
* For more documentation about the callback functions and the
14-
* parameters they are called with see testharness.js
2+
* Prepare a report object containing all tests results.
3+
* https://wpt-docs.readthedocs.io/en/latest/_writing-tests/testharness-api.html#callback-api
154
*/
5+
var report = {
6+
status: "",
7+
log: "no test suite completion|Fail|The test never reaches the completion callback.",
8+
cases: {},
9+
};
1610

17-
/* If the parent window has a testharness_properties object,
18-
* we use this to provide the test settings. This is used by the
19-
* default in-browser runner to configure the timeout and the
20-
* rendering of results
21-
*/
22-
try {
23-
if (window.opener && "testharness_properties" in window.opener) {
24-
/* If we pass the testharness_properties object as-is here without
25-
* JSON stringifying and reparsing it, IE fails & emits the message
26-
* "Could not complete the operation due to error 80700019".
27-
*/
28-
setup(JSON.parse(JSON.stringify(window.opener.testharness_properties)));
29-
}
30-
} catch (e) {
11+
function format(test) {
12+
var log = test.name+"|"+test.format_status();
13+
if (test.message != null) {
14+
log += "|"+test.message.replaceAll("\n"," ");
15+
}
16+
17+
return log;
3118
}
32-
// vim: set expandtab shiftwidth=4 tabstop=4:
19+
20+
function update() {
21+
var log = "";
22+
Object.keys(report.cases).forEach((k, i) => {
23+
log += report.cases[k] + "\n";
24+
});
25+
report.log = log;
26+
}
27+
28+
add_test_state_callback(function (test) {
29+
report.cases[test.name] = format(test);
30+
update();
31+
});
32+
33+
add_result_callback(function (test) {
34+
report.cases[test.name] = format(test);
35+
update();
36+
});

0 commit comments

Comments
 (0)