Skip to content

Commit fb2910a

Browse files
committed
fixup! test: accomodate multi-global tests in WPT{Runner,TestSpec,Report}
1 parent b87e5c5 commit fb2910a

5 files changed

Lines changed: 71 additions & 65 deletions

File tree

test/common/wpt.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,14 @@ class WPTTestSpec {
324324
this.filename = filename;
325325
this.variant = variant;
326326
this.globalScope = globalScope;
327+
this.rules = [...new Set(rules)];
327328

328329
this.requires = new Set();
329330
this.failedTests = [];
330331
this.flakyTests = [];
331332
this.skipReasons = [];
332333
this.skippedTests = [];
333-
for (const item of rules) {
334+
for (const item of this.rules) {
334335
if (item.requires.length) {
335336
for (const req of item.requires) {
336337
this.requires.add(req);
@@ -648,6 +649,31 @@ const limit = (concurrency) => {
648649
return execute;
649650
};
650651

652+
function getUnexpectedPasses(queue, results) {
653+
const specsByRule = new Map();
654+
for (const spec of queue) {
655+
for (const rule of spec.rules) {
656+
if (Array.isArray(rule.fail?.expected)) {
657+
const specs = specsByRule.get(rule) || [];
658+
specs.push(spec);
659+
specsByRule.set(rule, specs);
660+
}
661+
}
662+
}
663+
664+
const unexpectedPasses = [];
665+
for (const [rule, specs] of specsByRule) {
666+
for (const expectedToFail of rule.fail.expected) {
667+
const failed = specs.some((spec) =>
668+
results[spec.getStatusKey()]?.fail?.expected?.includes(expectedToFail));
669+
if (!failed) {
670+
unexpectedPasses.push(`${rule.key}:${expectedToFail}`);
671+
}
672+
}
673+
}
674+
return unexpectedPasses;
675+
}
676+
651677
class WPTRunner {
652678
constructor(path, { concurrency = os.availableParallelism() - 1 || 1 } = {}) {
653679
// RISC-V has very limited virtual address space in the currently common
@@ -907,32 +933,7 @@ class WPTRunner {
907933
}
908934
}
909935

910-
const unexpectedPasses = [];
911-
for (const specs of queue) {
912-
const key = specs.getStatusKey();
913-
914-
// File has no expected failures
915-
if (!specs.failedTests.length) {
916-
continue;
917-
}
918-
919-
// File was (maybe even conditionally) skipped
920-
if (this.results[key]?.skip) {
921-
continue;
922-
}
923-
924-
// Full check: every expected to fail test is present
925-
const _unexpectedPasses = specs.failedTests.filter((expectedToFail) => {
926-
if (specs.flakyTests.includes(expectedToFail)) {
927-
return false;
928-
}
929-
return this.results[key]?.fail?.expected?.includes(expectedToFail) !== true;
930-
});
931-
if (_unexpectedPasses.length) {
932-
unexpectedPasses.push(..._unexpectedPasses.map((name) => `${key}:${name}`));
933-
continue;
934-
}
935-
}
936+
const unexpectedPasses = getUnexpectedPasses(queue, this.results);
936937

937938
// Write the report on clean exit. The report is also written
938939
// incrementally after each spec completes (see completionCallback)
@@ -1171,6 +1172,7 @@ class WPTRunner {
11711172
}
11721173

11731174
module.exports = {
1175+
getUnexpectedPasses,
11741176
harness: harnessMock,
11751177
ResourceLoader,
11761178
WPTTestSpec,

test/parallel/test-common-wpt-any.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
require('../common');
44
const assert = require('assert');
5-
const { WPTTestSpec } = require('../common/wpt');
5+
const {
6+
getUnexpectedPasses,
7+
WPTTestSpec,
8+
} = require('../common/wpt');
69

710
const specs = WPTTestSpec.from(
811
'WebCryptoAPI',
@@ -71,3 +74,38 @@ assert.deepStrictEqual(
7174
scopedSpecs.map(({ skipReasons }) => skipReasons),
7275
[[], ['worker only']],
7376
);
77+
78+
const sourceRule = {
79+
key: 'getPublicKey.tentative.https.any.js',
80+
requires: [],
81+
fail: { expected: ['shared failure'] },
82+
};
83+
const workerRule = {
84+
key: 'getPublicKey.tentative.https.any.worker.html',
85+
requires: [],
86+
fail: { expected: ['worker failure'] },
87+
};
88+
const expectedFailureSpecs = WPTTestSpec.from(
89+
'WebCryptoAPI',
90+
'getPublicKey.tentative.https.any.js',
91+
[sourceRule],
92+
(spec) => (spec.isWebWorkerTest() ? [workerRule] : []),
93+
);
94+
const expectedResults = {
95+
'getPublicKey.tentative.https.any.html': {
96+
fail: { expected: ['shared failure'] },
97+
},
98+
'getPublicKey.tentative.https.any.worker.html': {
99+
fail: { expected: ['worker failure'] },
100+
},
101+
};
102+
103+
assert.deepStrictEqual(
104+
getUnexpectedPasses(expectedFailureSpecs, expectedResults),
105+
[],
106+
);
107+
delete expectedResults['getPublicKey.tentative.https.any.worker.html'].fail;
108+
assert.deepStrictEqual(
109+
getUnexpectedPasses(expectedFailureSpecs, expectedResults),
110+
['getPublicKey.tentative.https.any.worker.html:worker failure'],
111+
);

test/wpt/status/hr-time.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
},
2020
} : {}),
2121

22-
'idlharness.any.html': {
22+
'idlharness.any.js': {
2323
fail: {
2424
expected: [
2525
'Window interface: attribute performance',

test/wpt/status/wasm/jsapi.json

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@
55
"esm-integration/namespace-instance.tentative.any.js": {
66
"skip": "pending https://github.com/nodejs/node/pull/59024"
77
},
8-
"esm-integration/source-phase-string-builtins.tentative.any.worker.html": {
9-
"fail": {
10-
"note": "TODO(avivkeller): expected? investigate",
11-
"expected": [
12-
"String builtins should be supported in source phase imports",
13-
"Source phase import should properly expose string builtin exports",
14-
"Source phase import should handle string builtin import reflection correctly"
15-
]
16-
}
17-
},
18-
"esm-integration/source-phase-string-constants.tentative.any.worker.html": {
19-
"fail": {
20-
"note": "TODO(avivkeller): expected? investigate",
21-
"expected": [
22-
"String constants from wasm:js/string-constants should be supported in source phase imports",
23-
"Source phase import should properly expose string constants exports",
24-
"Source phase import should handle string constants import reflection correctly"
25-
]
26-
}
27-
},
28-
"esm-integration/source-phase.tentative.any.worker.html": {
29-
"fail": {
30-
"note": "TODO(avivkeller): expected? investigate",
31-
"expected": [
32-
"Source phase imports"
33-
]
34-
}
35-
},
368
"esm-integration/v128-tdz.tentative.any.js": {
379
"skip": "v128 undefined Wasm bindings not yet supported in V8"
3810
},

test/wpt/status/webidl.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
]
2121
}
2222
},
23-
"ecmascript-binding/global-object-implicit-this-value.any.html": {
23+
"ecmascript-binding/global-object-implicit-this-value.any.js": {
2424
"fail": {
2525
"expected": [
2626
"Global object's getter throws when called on incompatible object",
@@ -34,13 +34,7 @@
3434
},
3535
"ecmascript-binding/global-object-implicit-this-value.any.worker.html": {
3636
"fail": {
37-
"note": "TODO(avivkeller): expected? investigate",
3837
"expected": [
39-
"Global object's getter throws when called on incompatible object",
40-
"Global object's setter throws when called on incompatible object",
41-
"Global object's operation throws when called on incompatible object",
42-
"Global object's getter works when called on null / undefined",
43-
"Global object's setter works when called on null / undefined",
4438
"Global object's operation works when called on null / undefined"
4539
]
4640
}
@@ -59,7 +53,7 @@
5953
]
6054
}
6155
},
62-
"ecmascript-binding/no-regexp-special-casing.any.html": {
56+
"ecmascript-binding/no-regexp-special-casing.any.js": {
6357
"fail": {
6458
"expected": [
6559
"Can be used as an object implementing a callback interface"

0 commit comments

Comments
 (0)