mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
test: update WPT runner
PR-URL: https://github.com/nodejs/node/pull/43455 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
d57178cdfc
commit
11f74e72a7
17 files changed
+3610
-140
No files matched your search
+66
-14
@@ -5,6 +5,7 @@ const fixtures = require('../common/fixtures');
|
||||
const fs = require('fs');
|
||||
const fsPromises = fs.promises;
|
||||
const path = require('path');
|
||||
const events = require('events');
|
||||
const { inspect } = require('util');
|
||||
const { Worker } = require('worker_threads');
|
||||
|
||||
@@ -152,7 +153,8 @@ class WPTTestSpec {
|
||||
this.filename = filename;
|
||||
|
||||
this.requires = new Set();
|
||||
this.failReasons = [];
|
||||
this.failedTests = [];
|
||||
this.flakyTests = [];
|
||||
this.skipReasons = [];
|
||||
for (const item of rules) {
|
||||
if (item.requires.length) {
|
||||
@@ -160,13 +162,21 @@ class WPTTestSpec {
|
||||
this.requires.add(req);
|
||||
}
|
||||
}
|
||||
if (item.fail) {
|
||||
this.failReasons.push(item.fail);
|
||||
if (Array.isArray(item.fail?.expected)) {
|
||||
this.failedTests.push(...item.fail.expected);
|
||||
}
|
||||
if (Array.isArray(item.fail?.flaky)) {
|
||||
this.failedTests.push(...item.fail.flaky);
|
||||
this.flakyTests.push(...item.fail.flaky);
|
||||
}
|
||||
if (item.skip) {
|
||||
this.skipReasons.push(item.skip);
|
||||
}
|
||||
}
|
||||
|
||||
this.failedTests = [...new Set(this.failedTests)];
|
||||
this.flakyTests = [...new Set(this.flakyTests)];
|
||||
this.skipReasons = [...new Set(this.skipReasons)];
|
||||
}
|
||||
|
||||
getRelativePath() {
|
||||
@@ -368,7 +378,7 @@ class WPTRunner {
|
||||
|
||||
// TODO(joyeecheung): work with the upstream to port more tests in .html
|
||||
// to .js.
|
||||
runJsTests() {
|
||||
async runJsTests() {
|
||||
let queue = [];
|
||||
|
||||
// If the tests are run as `node test/wpt/test-something.js subset.any.js`,
|
||||
@@ -459,6 +469,8 @@ class WPTRunner {
|
||||
);
|
||||
this.inProgress.delete(testFileName);
|
||||
});
|
||||
|
||||
await events.once(worker, 'exit').catch(() => {});
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
@@ -469,34 +481,72 @@ class WPTRunner {
|
||||
}
|
||||
}
|
||||
inspect.defaultOptions.depth = Infinity;
|
||||
console.log(this.results);
|
||||
// Sorts the rules to have consistent output
|
||||
console.log(JSON.stringify(Object.keys(this.results).sort().reduce(
|
||||
(obj, key) => {
|
||||
obj[key] = this.results[key];
|
||||
return obj;
|
||||
},
|
||||
{}
|
||||
), null, 2));
|
||||
|
||||
const failures = [];
|
||||
let expectedFailures = 0;
|
||||
let skipped = 0;
|
||||
for (const key of Object.keys(this.results)) {
|
||||
const item = this.results[key];
|
||||
if (item.fail && item.fail.unexpected) {
|
||||
for (const [key, item] of Object.entries(this.results)) {
|
||||
if (item.fail?.unexpected) {
|
||||
failures.push(key);
|
||||
}
|
||||
if (item.fail && item.fail.expected) {
|
||||
if (item.fail?.expected) {
|
||||
expectedFailures++;
|
||||
}
|
||||
if (item.skip) {
|
||||
skipped++;
|
||||
}
|
||||
}
|
||||
|
||||
const unexpectedPasses = [];
|
||||
for (const [key, specMap] of this.specMap) {
|
||||
// File has no expected failures
|
||||
if (!specMap.failedTests.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// File was (maybe even conditionally) skipped
|
||||
if (this.results[key]?.skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Full check: every expected to fail test is present
|
||||
if (specMap.failedTests.some((expectedToFail) => {
|
||||
if (specMap.flakyTests.includes(expectedToFail)) {
|
||||
return false;
|
||||
}
|
||||
return this.results[key]?.fail?.expected?.includes(expectedToFail) !== true;
|
||||
})) {
|
||||
unexpectedPasses.push(key);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const ran = total - skipped;
|
||||
const passed = ran - expectedFailures - failures.length;
|
||||
console.log(`Ran ${ran}/${total} tests, ${skipped} skipped,`,
|
||||
`${passed} passed, ${expectedFailures} expected failures,`,
|
||||
`${failures.length} unexpected failures`);
|
||||
`${failures.length} unexpected failures,`,
|
||||
`${unexpectedPasses.length} unexpected passes`);
|
||||
if (failures.length > 0) {
|
||||
const file = path.join('test', 'wpt', 'status', `${this.path}.json`);
|
||||
throw new Error(
|
||||
`Found ${failures.length} unexpected failures. ` +
|
||||
`Consider updating ${file} for these files:\n${failures.join('\n')}`);
|
||||
}
|
||||
if (unexpectedPasses.length > 0) {
|
||||
const file = path.join('test', 'wpt', 'status', `${this.path}.json`);
|
||||
throw new Error(
|
||||
`Found ${unexpectedPasses.length} unexpected passes. ` +
|
||||
`Consider updating ${file} for these files:\n${unexpectedPasses.join('\n')}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -577,8 +627,9 @@ class WPTRunner {
|
||||
if (!result[item.status][key]) {
|
||||
result[item.status][key] = [];
|
||||
}
|
||||
if (result[item.status][key].indexOf(item.reason) === -1) {
|
||||
result[item.status][key].push(item.reason);
|
||||
const hasName = result[item.status][key].includes(item.name);
|
||||
if (!hasName) {
|
||||
result[item.status][key].push(item.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -589,10 +640,10 @@ class WPTRunner {
|
||||
|
||||
fail(filename, test, status) {
|
||||
const spec = this.specMap.get(filename);
|
||||
const expected = !!(spec.failReasons.length);
|
||||
const expected = spec.failedTests.includes(test.name);
|
||||
if (expected) {
|
||||
console.log(`[EXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`);
|
||||
console.log(spec.failReasons.join('; '));
|
||||
console.log(test.message || status);
|
||||
} else {
|
||||
console.log(`[UNEXPECTED_FAILURE][${status.toUpperCase()}] ${test.name}`);
|
||||
}
|
||||
@@ -604,6 +655,7 @@ class WPTRunner {
|
||||
` ${require.main.filename} ${filename}`;
|
||||
console.log(`Command: ${command}\n`);
|
||||
this.addTestResult(filename, {
|
||||
name: test.name,
|
||||
expected,
|
||||
status: kFail,
|
||||
reason: test.message || status
|
||||
|
||||
+16
-3
@@ -91,7 +91,11 @@ add this to `test/wpt/status/url.json`:
|
||||
|
||||
```json
|
||||
"url-searchparams.any.js": {
|
||||
"fail": "explain why the test fails, ideally with links"
|
||||
"fail": {
|
||||
"expected": [
|
||||
"test name in the WPT test case, e.g. second argument passed to test()"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -155,8 +159,17 @@ expected failures.
|
||||
// Optional: the test will be skipped with the reason printed
|
||||
"skip": "explain why we cannot run a test that's supposed to pass",
|
||||
|
||||
// Optional: the test will be skipped with the reason printed
|
||||
"fail": "explain why we the test is expected to fail"
|
||||
// Optional: failing tests
|
||||
"fail": {
|
||||
"note": "You may leave an optional arbitrary note e.g. with TODOs",
|
||||
"expected": [
|
||||
"test name in the WPT test case, e.g. second argument passed to test()",
|
||||
"another test name"
|
||||
],
|
||||
"flaky": [
|
||||
"flaky test name"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,14 +1,47 @@
|
||||
{
|
||||
"Blob-constructor.any.js": {
|
||||
"skip": "Depends on File API"
|
||||
},
|
||||
"Blob-constructor-dom.window.js": {
|
||||
"skip": "Depends on DOM API"
|
||||
},
|
||||
"Blob-slice.any.js": {
|
||||
"skip": "Depends on File API"
|
||||
"Blob-constructor.any.js": {
|
||||
"fail": {
|
||||
"note": "Depends on File API",
|
||||
"expected": [
|
||||
"A plain object with @@iterator should be treated as a sequence for the blobParts argument.",
|
||||
"A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument.",
|
||||
"A String object should be treated as a sequence for the blobParts argument.",
|
||||
"A Uint8Array object should be treated as a sequence for the blobParts argument.",
|
||||
"Getters and value conversions should happen in order until an exception is thrown.",
|
||||
"Changes to the blobParts array should be reflected in the returned Blob (pop).",
|
||||
"Changes to the blobParts array should be reflected in the returned Blob (unshift).",
|
||||
"ToString should be called on elements of the blobParts array.",
|
||||
"ArrayBuffer elements of the blobParts array should be supported.",
|
||||
"Passing typed arrays as elements of the blobParts array should work.",
|
||||
"Passing a Float64Array as element of the blobParts array should work.",
|
||||
"Array with two blobs",
|
||||
"Array with two buffers",
|
||||
"Array with two bufferviews",
|
||||
"Array with mixed types",
|
||||
"options properties should be accessed in lexicographic order.",
|
||||
"Arguments should be evaluated from left to right.",
|
||||
"Passing null (index 0) for options should use the defaults.",
|
||||
"Passing null (index 0) for options should use the defaults (with newlines).",
|
||||
"Passing undefined (index 1) for options should use the defaults.",
|
||||
"Passing undefined (index 1) for options should use the defaults (with newlines).",
|
||||
"Passing object \"[object Object]\" (index 2) for options should use the defaults.",
|
||||
"Passing object \"[object Object]\" (index 2) for options should use the defaults (with newlines).",
|
||||
"Passing object \"[object Object]\" (index 3) for options should use the defaults.",
|
||||
"Passing object \"[object Object]\" (index 3) for options should use the defaults (with newlines).",
|
||||
"Passing object \"/regex/\" (index 4) for options should use the defaults.",
|
||||
"Passing object \"/regex/\" (index 4) for options should use the defaults (with newlines).",
|
||||
"Passing function \"function() {}\" (index 5) for options should use the defaults.",
|
||||
"Passing function \"function() {}\" (index 5) for options should use the defaults (with newlines)."
|
||||
]
|
||||
}
|
||||
},
|
||||
"Blob-in-worker.worker.js": {
|
||||
"skip": "Depends on Web Workers API"
|
||||
},
|
||||
"Blob-slice.any.js": {
|
||||
"skip": "Depends on File API"
|
||||
}
|
||||
}
|
||||
+3411
-64
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"idlharness.any.js": {
|
||||
"fail": ".table, .dir and .timeLog parameter lengths are wrong"
|
||||
"fail": {
|
||||
"flaky": [
|
||||
"console namespace: operation assert(optional boolean, any...)",
|
||||
"console namespace: operation table(optional any, optional sequence<DOMString>)",
|
||||
"console namespace: operation dir(optional any, optional object?)"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,51 @@
|
||||
{
|
||||
"Event-dispatch-listener-order.window.js": { "fail": "document is not defined" },
|
||||
"AddEventListenerOptions-passive.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_equals: Incorrect defaultPrevented for options: {\"passive\":true} expected false but got true",
|
||||
"assert_equals: Incorrect defaultPrevented for options: undefined expected true but got false"
|
||||
"expected": [
|
||||
"preventDefault should be ignored if-and-only-if the passive option is true",
|
||||
"returnValue should be ignored if-and-only-if the passive option is true",
|
||||
"passive behavior of one listener should be unaffected by the presence of other listeners"
|
||||
]
|
||||
}
|
||||
},
|
||||
"AddEventListenerOptions-signal.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_throws_js: function \"() => { et.addEventListener(\"foo\", () => {}, { signal: null }); }\" did not throw",
|
||||
"assert_throws_js: function \"() => { et.addEventListener(\"foo\", null, { signal: null }); }\" did not throw"
|
||||
"expected": [
|
||||
"Passing null as the signal should throw",
|
||||
"Passing null as the signal should throw (listener is also null)"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Event-constructors.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_true: expected true got false",
|
||||
"assert_array_equals: lengths differ, expected array [\"bubbles\", \"cancelable\"] length 2, got [\"cancelable\", \"bubbles\", \"sweet\"] length 3"
|
||||
"expected": [
|
||||
"Untitled 2",
|
||||
"Untitled 3"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Event-dispatch-listener-order.window.js": {
|
||||
"skip": "document is not defined"
|
||||
},
|
||||
"EventListener-addEventListener.sub.window.js": {
|
||||
"fail": "document is not defined"
|
||||
},
|
||||
"relatedTarget.window.js": {
|
||||
"fail": "document is not defined"
|
||||
},
|
||||
"event-global.worker.js": {
|
||||
"fail": "importScripts is not defined"
|
||||
},
|
||||
"event-global-extra.window.js": {
|
||||
"fail": "document is not defined"
|
||||
},
|
||||
"legacy-pre-activation-behavior.window.js": {
|
||||
"fail": "document is not defined"
|
||||
},
|
||||
"event-global-set-before-handleEvent-lookup.window.js": {
|
||||
"fail": "window is not defined"
|
||||
"skip": "document is not defined"
|
||||
},
|
||||
"EventTarget-removeEventListener.any.js": {
|
||||
"fail": "globalThis.removeEventListener is not a function"
|
||||
"skip": "globalThis.removeEventListener is not a function"
|
||||
},
|
||||
"event-global-extra.window.js": {
|
||||
"skip": "document is not defined"
|
||||
},
|
||||
"event-global-set-before-handleEvent-lookup.window.js": {
|
||||
"skip": "window is not defined"
|
||||
},
|
||||
"event-global.worker.js": {
|
||||
"skip": "importScripts is not defined"
|
||||
},
|
||||
"legacy-pre-activation-behavior.window.js": {
|
||||
"skip": "document is not defined"
|
||||
},
|
||||
"relatedTarget.window.js": {
|
||||
"skip": "document is not defined"
|
||||
}
|
||||
}
|
||||
@@ -22,25 +22,25 @@
|
||||
},
|
||||
"iso-2022-jp-decoder.any.js": {
|
||||
"requires": ["full-icu"],
|
||||
"fail": "iso-2022-jp decoder state handling bug: https://encoding.spec.whatwg.org/#iso-2022-jp-decoder"
|
||||
"skip": "iso-2022-jp decoder state handling bug: https://encoding.spec.whatwg.org/#iso-2022-jp-decoder"
|
||||
},
|
||||
"textdecoder-byte-order-marks.any.js": {
|
||||
"requires": ["small-icu"]
|
||||
},
|
||||
"textdecoder-fatal-single-byte.any.js": {
|
||||
"requires": ["full-icu"],
|
||||
"fail": "The iso-8859-16 encoding is not supported"
|
||||
"skip": "The iso-8859-16 encoding is not supported"
|
||||
},
|
||||
"textdecoder-labels.any.js": {
|
||||
"requires": ["full-icu"],
|
||||
"fail": "The iso-8859-16 encoding is not supported"
|
||||
"skip": "The iso-8859-16 encoding is not supported"
|
||||
},
|
||||
"textencoder-constructor-non-utf.any.js": {
|
||||
"requires": ["full-icu"],
|
||||
"fail": "The iso-8859-16 encoding is not supported"
|
||||
"skip": "The iso-8859-16 encoding is not supported"
|
||||
},
|
||||
"idlharness.any.js": {
|
||||
"fail": "No implementation of TextDecoderStream and TextEncoderStream"
|
||||
"skip": "No implementation of TextDecoderStream and TextEncoderStream"
|
||||
},
|
||||
"replacement-encodings.any.js": {
|
||||
"skip": "decoding-helpers.js needs XMLHttpRequest"
|
||||
@@ -63,15 +63,15 @@
|
||||
"streams/decode-utf8.any.js": {
|
||||
"requires": ["small-icu"],
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"promise_test: Unhandled rejection with value: object 'TypeError: Cannot perform Construct on a detached ArrayBuffer'"
|
||||
"expected": [
|
||||
"decoding a transferred ArrayBuffer chunk should give no output"
|
||||
]
|
||||
}
|
||||
},
|
||||
"streams/decode-bad-chunks.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_unreached: Should have rejected: write should reject Reached unreachable code"
|
||||
"expected": [
|
||||
"chunk of type undefined should error the stream"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"skip": "TODO: update IDL parser"
|
||||
},
|
||||
"window-worker-timeOrigin.window.js": {
|
||||
"fail": "depends on URL.createObjectURL(blob)"
|
||||
"skip": "depends on URL.createObjectURL(blob)"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"base64.any.js": {
|
||||
"fail": "promise_test: Unhandled rejection with value: object \"Error: ENOENT: no such file or directory, open '/root/node/node/fetch/data-urls/resources/base64.json'\""
|
||||
"skip": "no such file or directory fetch/data-urls/resources/base64.json"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"queue-microtask-exceptions.any.js": {
|
||||
"fail": "Node.js does not have a global addEventListener function"
|
||||
"skip": "Node.js does not have a global addEventListener function"
|
||||
},
|
||||
"queue-microtask.window.js": {
|
||||
"fail": "MutationObserver is not implemented"
|
||||
"skip": "MutationObserver is not implemented"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"negative-settimeout.any.js": {
|
||||
"fail": "unreliable in Node.js; Refs: https://github.com/nodejs/node/issues/37672"
|
||||
"skip": "unreliable in Node.js; Refs: https://github.com/nodejs/node/issues/37672"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
{
|
||||
"case-sensitivity.any.js": {
|
||||
"fail": "resource entry type not supported"
|
||||
"fail": {
|
||||
"note": "resource entry type not supported",
|
||||
"expected": [
|
||||
"getEntriesByType values are case sensitive",
|
||||
"getEntriesByName values are case sensitive"
|
||||
]
|
||||
}
|
||||
},
|
||||
"idlharness.any.js": {
|
||||
"skip": "idlharness cannot recognize Node.js environment"
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
"skip": "Browser-specific test"
|
||||
},
|
||||
"readable-byte-streams/bad-buffers-and-views.any.js": {
|
||||
"fail": "TODO: implement detached ArrayBuffer support"
|
||||
"fail": {
|
||||
"note": "TODO: implement detached ArrayBuffer support",
|
||||
"expected": [
|
||||
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer is zero-length (in the readable state)"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
"origin.sub.any.js": {
|
||||
"skip": "CORS not implemented"
|
||||
},
|
||||
|
||||
"abort.any.js": {
|
||||
"skip": "WPTRunner does not support fetch()"
|
||||
},
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
{
|
||||
"basics.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_equals: origin expected \"https://example.com\" but got \"\"",
|
||||
"assert_equals: target for event 0 expected object \"[object EventTarget]\" but got object \"[object EventTarget]\""
|
||||
"expected": [
|
||||
"postMessage results in correct event",
|
||||
"messages are delivered in port creation order"
|
||||
],
|
||||
"flaky": [
|
||||
"Closing a channel in onmessage prevents already queued tasks from firing onmessage events"
|
||||
]
|
||||
}
|
||||
},
|
||||
"interface.any.js": {
|
||||
"fail": {
|
||||
"unexpected": [
|
||||
"assert_throws_dom: function \"() => c.postMessage('')\" threw object \"Error: BroadcastChannel is closed.\" that is not a DOMException InvalidStateError: property \"code\" is equal to 0, expected 11",
|
||||
"assert_not_equals: got disallowed value undefined",
|
||||
"assert_throws_dom: function \"() => c.postMessage(new Symbol())\" threw object \"Error: BroadcastChannel is closed.\" that is not a DOMException InvalidStateError: property \"code\" is equal to 0, expected 11"
|
||||
"expected": [
|
||||
"postMessage after close should throw",
|
||||
"postMessage should throw InvalidStateError after close, even with uncloneable data"
|
||||
]
|
||||
}
|
||||
},
|
||||
"origin.window.js": {
|
||||
"fail": {
|
||||
"expected": [
|
||||
"document is not defined"
|
||||
"Serialization of BroadcastChannel origin"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,8 @@ const runner = new WPTRunner('WebCryptoAPI');
|
||||
// Set Node.js flags required for the tests.
|
||||
runner.setFlags(['--experimental-global-webcrypto']);
|
||||
|
||||
runner.setInitScript(`
|
||||
global.location = {};
|
||||
`);
|
||||
|
||||
runner.runJsTests();
|
||||
+1
-1
@@ -957,7 +957,7 @@ class Context(object):
|
||||
|
||||
def GetTimeout(self, mode, section=''):
|
||||
timeout = self.timeout * TIMEOUT_SCALEFACTOR[ARCH_GUESS or 'ia32'][mode]
|
||||
if section == 'pummel' or section == 'benchmark':
|
||||
if section == 'pummel' or section == 'benchmark' or section == 'wpt':
|
||||
timeout = timeout * 6
|
||||
return timeout
|
||||
|
||||
|
||||
Reference in new issue
Block a user