test: allow skipping individual WPT subtests · nodejs/node@f1a6e9f · GitHub
Skip to content

Commit f1a6e9f

Browse files
panvaaduh95
authored andcommitted
test: allow skipping individual WPT subtests
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #62517 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 6f37f7e commit f1a6e9f

3 files changed

Lines changed: 112 additions & 4 deletions

File tree

test/common/wpt.js

Lines changed: 49 additions & 3 deletions

test/common/wpt/worker.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ runInThisContext(workerData.harness.code, {
3535
filename: workerData.harness.filename,
3636
});
3737

38+
// If there are skip patterns, wrap test functions to prevent execution of
39+
// matching tests. This must happen after testharness.js is loaded but before
40+
// the test scripts run.
41+
if (workerData.skippedTests?.length) {
42+
function isSkipped(name) {
43+
for (const matcher of workerData.skippedTests) {
44+
if (typeof matcher === 'string') {
45+
if (name === matcher) return true;
46+
} else if (matcher.test(name)) {
47+
return true;
48+
}
49+
}
50+
return false;
51+
}
52+
for (const fn of ['test', 'async_test', 'promise_test']) {
53+
const original = globalThis[fn];
54+
globalThis[fn] = function(func, name, ...rest) {
55+
if (typeof name === 'string' && isSkipped(name)) {
56+
parentPort.postMessage({ type: 'skip', name });
57+
return;
58+
}
59+
return original.call(this, func, name, ...rest);
60+
};
61+
}
62+
}
63+
3864
// eslint-disable-next-line no-undef
3965
add_result_callback((result) => {
4066
parentPort.postMessage({

test/wpt/README.md

Lines changed: 37 additions & 1 deletion

0 commit comments

Comments
 (0)