From d04cfcda8ec6c1c6dbab1b76539ca2a67cf3c181 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Tue, 4 Aug 2026 13:05:12 +0200 Subject: [PATCH] test: add opt-in process WPT runner To hopefully get to the bottom of WPT crashes that have no traces. Signed-off-by: Filip Skokan Co-authored-by: Aviv Keller Signed-off-by: Aviv Keller PR-URL: https://github.com/nodejs/node/pull/64894 Fixes: https://github.com/nodejs/node/issues/43583 Reviewed-By: Filip Skokan Reviewed-By: James M Snell Reviewed-By: Matthew Aitken Reviewed-By: Chengzhong Wu --- test/common/wpt.js | 283 ++++++++++++++++------ test/common/wpt/worker.js | 198 ++++++++------- test/fixtures/wpt-backends-spec.js | 24 ++ test/parallel/test-common-wpt-any.js | 4 + test/parallel/test-common-wpt-backends.js | 184 ++++++++++++++ test/wpt/test-compression.js | 3 +- test/wpt/test-streams.js | 3 +- test/wpt/test-wasm-jsapi.mjs | 3 +- test/wpt/test-webcrypto.js | 3 +- 9 files changed, 540 insertions(+), 165 deletions(-) create mode 100644 test/fixtures/wpt-backends-spec.js create mode 100644 test/parallel/test-common-wpt-backends.js diff --git a/test/common/wpt.js b/test/common/wpt.js index 23f41944eaf..0bf56e358d9 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -9,6 +9,7 @@ const events = require('events'); const os = require('os'); const { inspect } = require('util'); const { Worker } = require('worker_threads'); +const { fork } = require('child_process'); const workerPath = path.join(__dirname, 'wpt/worker.js'); const kRunWorkerGlobals = false; @@ -451,7 +452,10 @@ class WPTTestSpec { return true; } const [filename, variant = ''] = arg.split('?'); - return filename === this.filename && + // Spec filenames are relative paths, so they use the platform separator, + // while the argument is written with forward slashes. + return filename.split(path.sep).join('/') === + this.filename.split(path.sep).join('/') && (!variant || this.variant.substring(1) === variant); } @@ -632,23 +636,28 @@ const limit = (concurrency) => { let running = 0; const queue = []; - const execute = async (fn) => { - if (running < concurrency) { - running++; - try { - await fn(); - } finally { - running--; - if (queue.length > 0) { - execute(queue.shift()); - } + const execute = async ({ fn, resolve, reject }) => { + running++; + try { + resolve(await fn()); + } catch (err) { + reject(err); + } finally { + running--; + if (queue.length > 0) { + execute(queue.shift()); } - } else { - queue.push(fn); } }; - return execute; + return (fn) => new Promise((resolve, reject) => { + const task = { fn, resolve, reject }; + if (running < concurrency) { + execute(task); + } else { + queue.push(task); + } + }); }; function isUnexpectedPass(spec, name) { @@ -683,8 +692,111 @@ function getHarnessErrorName(harnessStatus) { return harnessStatus.message || 'WPT test harness error'; } +/** + * @typedef {object} SpecHandlers + * @property {(message: object) => void} message Handles a message from the spec. + * @property {(failure: { name: string, message: string, stack: string }) + * => boolean} failure Reports a spec that died without completing. Returns + * false when the spec had already finished and the failure was ignored. + */ + +/** + * @typedef {object} SpecHandle + * @property {() => void} kill Forces the spec to stop running. + * @property {Promise} finished Settles once the spec has stopped. + */ + +/** + * Run a spec on a worker thread. + * @param {string[]} execArgv + * @param {object} workerData + * @param {SpecHandlers} handlers + * @returns {SpecHandle} + */ +function runSpecOnThread(execArgv, workerData, handlers) { + const worker = new Worker(workerPath, { execArgv, workerData }); + worker.on('message', handlers.message); + worker.on('error', (err) => handlers.failure({ + name: `${err}`, + message: err.message, + stack: inspect(err), + })); + return { + kill: () => worker.terminate(), + finished: events.once(worker, 'exit').catch(() => {}), + }; +} + +/** + * Run a spec in a child process, so that a spec crashing the process only + * takes down its own run and the runner can attribute the crash to it. + * @param {string[]} execArgv + * @param {object} workerData + * @param {SpecHandlers} handlers + * @returns {SpecHandle} + */ +function runSpecInProcess(execArgv, workerData, handlers) { + const child = fork(workerPath, { + execArgv, + // Status files may skip subtests by regular expression, which JSON + // serialization would not preserve. + serialization: 'advanced', + stdio: ['ignore', 'inherit', 'pipe', 'ipc'], + }); + child.send(workerData); + + let stderr = ''; + child.stderr.setEncoding('utf8'); + child.stderr.on('data', (chunk) => { + stderr += chunk; + }); + + child.on('message', (message) => { + // The spec reports uncaught errors itself so that they are named the same + // way as they would be on the worker thread backend. + if (message.type === 'uncaught') { + handlers.failure(message.error); + return; + } + handlers.message(message); + }); + child.on('error', (err) => handlers.failure({ + name: `${err}`, + message: err.message, + stack: inspect(err), + })); + // `close` rather than `exit` so that everything the process wrote to stderr + // on its way out is part of the reported failure. + child.on('close', (code, signal) => { + const name = signal ? + `Test process was killed by signal ${signal}` : + `Test process exited with code ${code}`; + if (!handlers.failure({ name, message: name, stack: stderr }) && stderr) { + process.stderr.write(stderr); + } + }); + + return { + kill: () => child.kill('SIGKILL'), + finished: events.once(child, 'close').catch(() => {}), + }; +} + +const backends = { + __proto__: null, + thread: runSpecOnThread, + process: runSpecInProcess, +}; + class WPTRunner { - constructor(path, { concurrency = os.availableParallelism() - 1 || 1 } = {}) { + constructor(path, { + concurrency = os.availableParallelism() - 1 || 1, + backend = 'thread', + } = {}) { + if (!Number.isInteger(concurrency) || concurrency < 1) { + throw new TypeError('WPT concurrency must be a positive integer'); + } + // RISC-V has very limited virtual address space in the currently common // sv39 mode, in which we can only create a very limited number of wasm // memories(27 from a fresh node repl). Limit the concurrency to avoid @@ -693,6 +805,15 @@ class WPTRunner { concurrency = Math.min(10, concurrency); } + // The override exists so that every suite can be run either way without + // editing the drivers, which is how the two backends are kept compatible. + backend = process.env.WPT_BACKEND || backend; + this.runSpec = backends[backend]; + if (this.runSpec === undefined) { + throw new Error(`Invalid WPT backend ${backend}, expected one of ` + + `${Object.keys(backends).join(', ')}`); + } + this.path = path; this.resource = new ResourceLoader(path); this.concurrency = concurrency; @@ -708,7 +829,7 @@ class WPTRunner { this.results = {}; this.inProgress = new Set(); - this.workers = new Map(); + this.handles = new Map(); this.unexpectedFailures = []; this.skippedSpecCount = 0; @@ -803,6 +924,7 @@ class WPTRunner { const queue = this.buildQueue(); const run = limit(this.concurrency); + const jobs = []; for (const spec of queue) { const content = spec.getContent(); @@ -828,66 +950,55 @@ class WPTRunner { this.scriptsModifier?.(obj); scriptsToRun.push(obj); - run(async () => { - const worker = new Worker(workerPath, { - execArgv: this.flags, - workerData: { - testRelativePath: relativePath, - wptRunner: __filename, - wptPath: this.path, - initScript: this.fullInitScript(spec), - harness: { - code: fs.readFileSync(harnessPath, 'utf8'), - filename: harnessPath, - }, - scriptsToRun, - needsGc: !!meta.script?.find((script) => script === '/common/gc.js'), - skippedTests: spec.skippedTests, + jobs.push(run(async () => { + this.inProgress.add(spec); + const reportResult = this.report?.getResult(spec); + + const handle = this.runSpec(this.flags, { + testRelativePath: relativePath, + wptRunner: __filename, + wptPath: this.path, + initScript: this.fullInitScript(spec), + harness: { + code: fs.readFileSync(harnessPath, 'utf8'), + filename: harnessPath, + }, + scriptsToRun, + needsGc: !!meta.script?.find((script) => script === '/common/gc.js'), + skippedTests: spec.skippedTests, + }, { + message: (message) => { + switch (message.type) { + case 'result': + return this.resultCallback(spec, message.result, reportResult); + case 'skip': + return this.skipTest(spec, { name: message.name }, reportResult); + case 'completion': + return this.completionCallback(spec, message.status, reportResult); + default: + throw new Error(`Unexpected message from spec runner: ${message.type}`); + } + }, + failure: (failure) => { + if (!this.inProgress.has(spec)) { + // The test is already finished. Ignore anything that happens + // after it, including the runner terminating it itself. + return false; + } + // Generate a subtest failure for visibility. + // No need to record this synthetic failure with wpt.fyi. + this.fail(spec, { status: NODE_UNCAUGHT, ...failure }, kUncaught); + // Mark the whole test as failed in wpt.fyi report. + reportResult?.finish('ERROR'); + this.inProgress.delete(spec); + this.report?.write(); + return true; }, }); - this.inProgress.add(spec); - this.workers.set(spec, worker); + this.handles.set(spec, handle); - const reportResult = this.report?.getResult(spec); - worker.on('message', (message) => { - switch (message.type) { - case 'result': - return this.resultCallback(spec, message.result, reportResult); - case 'skip': - return this.skipTest(spec, { name: message.name }, reportResult); - case 'completion': - return this.completionCallback(spec, message.status, reportResult); - default: - throw new Error(`Unexpected message from worker: ${message.type}`); - } - }); - - worker.on('error', (err) => { - if (!this.inProgress.has(spec)) { - // The test is already finished. Ignore errors that occur after it. - // This can happen normally, for example in timers tests. - return; - } - // Generate a subtest failure for visibility. - // No need to record this synthetic failure with wpt.fyi. - this.fail( - spec, - { - status: NODE_UNCAUGHT, - name: `${err}`, - message: err.message, - stack: inspect(err), - }, - kUncaught, - ); - // Mark the whole test as failed in wpt.fyi report. - reportResult?.finish('ERROR'); - this.inProgress.delete(spec); - this.report?.write(); - }); - - await events.once(worker, 'exit').catch(() => {}); - }); + await handle.finished; + })); } process.on('exit', () => { @@ -955,6 +1066,25 @@ class WPTRunner { `Consider updating ${file} for these files:\n${unexpectedPasses.join('\n')}`); } }); + + // Promises do not keep the event loop alive. Keep a referenced handle + // until every queued spec has run, including the gap between terminating + // one spec runner and receiving its exit event. + const keepAlive = setInterval(() => {}, 2 ** 31 - 1); + try { + const outcomes = await Promise.allSettled(jobs); + const errors = outcomes + .filter((outcome) => outcome.status === 'rejected') + .map((outcome) => outcome.reason); + if (errors.length === 1) { + throw errors[0]; + } + if (errors.length > 1) { + throw new AggregateError(errors, 'Multiple WPT spec runners failed'); + } + } finally { + clearInterval(keepAlive); + } } // Map WPT test status to strings @@ -1021,9 +1151,9 @@ class WPTRunner { // Write report incrementally so results survive even if the process // is killed before the exit handler runs. this.report?.write(); - // Always force termination of the worker. Some tests allocate resources - // that would otherwise keep it alive. - this.workers.get(spec).terminate(); + // Always force termination of the spec runner. Some tests allocate + // resources that would otherwise keep it alive. + this.handles.get(spec).kill(); } addTestResult(spec, item) { @@ -1167,6 +1297,7 @@ class WPTRunner { } module.exports = { + backends, getHarnessErrorName, getUnexpectedPasses, harness: harnessMock, diff --git a/test/common/wpt/worker.js b/test/common/wpt/worker.js index 74a35419cd1..1f5c3ebc30c 100644 --- a/test/common/wpt/worker.js +++ b/test/common/wpt/worker.js @@ -6,101 +6,129 @@ const { constants: { USE_MAIN_CONTEXT_DEFAULT_LOADER }, } = require('vm'); const { setFlagsFromString } = require('v8'); -const { parentPort, workerData } = require('worker_threads'); +const { inspect } = require('util'); +const { + isMainThread, + parentPort, + workerData: threadData, +} = require('worker_threads'); -const { ResourceLoader } = require(workerData.wptRunner); -const resource = new ResourceLoader(workerData.wptPath); +// The runner starts this either on a worker thread, where the spec to run +// arrives as workerData, or in a child process, where it arrives over IPC. +const send = isMainThread ? + (message) => process.send(message) : + (message) => parentPort.postMessage(message); -if (workerData.needsGc) { - // See https://github.com/nodejs/node/issues/16595#issuecomment-340288680 - setFlagsFromString('--expose-gc'); - globalThis.gc = runInNewContext('gc'); +if (isMainThread) { + // A worker thread surfaces uncaught errors through its 'error' event; a + // process has to report them itself so that the runner names the failure + // exactly the same way. + process.on('uncaughtException', (err) => { + process.send({ + type: 'uncaught', + error: { name: `${err}`, message: err.message, stack: inspect(err) }, + }, () => process.exit(1)); + }); + process.once('message', run); +} else { + run(threadData); } -globalThis.self = global; -globalThis.GLOBAL = { - isWindow() { return false; }, - isShadowRealm() { return false; }, -}; -globalThis.require = require; +function run(workerData) { + const { ResourceLoader } = require(workerData.wptRunner); + const resource = new ResourceLoader(workerData.wptPath); -// This is a mock for non-fetch tests that use fetch to resolve -// a relative fixture file. -// Actual Fetch API WPTs are executed in nodejs/undici. -globalThis.fetch = function fetch(file) { - return resource.readAsFetch(workerData.testRelativePath, file); -}; + if (workerData.needsGc) { + // See https://github.com/nodejs/node/issues/16595#issuecomment-340288680 + setFlagsFromString('--expose-gc'); + globalThis.gc = runInNewContext('gc'); + } -if (workerData.initScript) { - runInThisContext(workerData.initScript, { + globalThis.self = global; + globalThis.GLOBAL = { + isWindow() { return false; }, + isShadowRealm() { return false; }, + }; + globalThis.require = require; + + // This is a mock for non-fetch tests that use fetch to resolve + // a relative fixture file. + // Actual Fetch API WPTs are executed in nodejs/undici. + globalThis.fetch = function fetch(file) { + return resource.readAsFetch(workerData.testRelativePath, file); + }; + + if (workerData.initScript) { + runInThisContext(workerData.initScript, { + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, + }); + } + + runInThisContext(workerData.harness.code, { + filename: workerData.harness.filename, importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, }); -} -runInThisContext(workerData.harness.code, { - filename: workerData.harness.filename, - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, -}); - -// If there are skip patterns, wrap test functions to prevent execution of -// matching tests. This must happen after testharness.js is loaded but before -// the test scripts run. -if (workerData.skippedTests?.length) { - function isSkipped(name) { - for (const matcher of workerData.skippedTests) { - if (typeof matcher === 'string') { - if (name === matcher) return true; - } else if (matcher.test(name)) { - return true; + // If there are skip patterns, wrap test functions to prevent execution of + // matching tests. This must happen after testharness.js is loaded but before + // the test scripts run. + if (workerData.skippedTests?.length) { + const isSkipped = (name) => { + for (const matcher of workerData.skippedTests) { + if (typeof matcher === 'string') { + if (name === matcher) return true; + } else if (matcher.test(name)) { + return true; + } } - } - return false; - } - for (const fn of ['test', 'async_test', 'promise_test']) { - const original = globalThis[fn]; - globalThis[fn] = function(func, name, ...rest) { - if (typeof name === 'string' && isSkipped(name)) { - parentPort.postMessage({ type: 'skip', name }); - return; - } - return original.call(this, func, name, ...rest); + return false; }; + for (const fn of ['test', 'async_test', 'promise_test']) { + const original = globalThis[fn]; + globalThis[fn] = function(func, name, ...rest) { + if (typeof name === 'string' && isSkipped(name)) { + send({ type: 'skip', name }); + return; + } + return original.call(this, func, name, ...rest); + }; + } + } + + // eslint-disable-next-line no-undef + add_result_callback((result) => { + send({ + type: 'result', + result: { + status: result.status, + name: result.name, + message: result.message, + stack: result.stack, + }, + }); + }); + + // Keep the event loop alive + const timeout = setTimeout(() => { + send({ + type: 'completion', + status: { status: 2 }, + }); + }, 2 ** 31 - 1); // Max timeout is 2^31-1, when overflown the timeout is set to 1. + + // eslint-disable-next-line no-undef + add_completion_callback((_, status) => { + clearTimeout(timeout); + send({ + type: 'completion', + status, + }); + }); + + for (const scriptToRun of workerData.scriptsToRun) { + runInThisContext(scriptToRun.code, { + filename: scriptToRun.filename, + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, + }); } } - -// eslint-disable-next-line no-undef -add_result_callback((result) => { - parentPort.postMessage({ - type: 'result', - result: { - status: result.status, - name: result.name, - message: result.message, - stack: result.stack, - }, - }); -}); - -// Keep the event loop alive -const timeout = setTimeout(() => { - parentPort.postMessage({ - type: 'completion', - status: { status: 2 }, - }); -}, 2 ** 31 - 1); // Max timeout is 2^31-1, when overflown the timeout is set to 1. - -// eslint-disable-next-line no-undef -add_completion_callback((_, status) => { - clearTimeout(timeout); - parentPort.postMessage({ - type: 'completion', - status, - }); -}); - -for (const scriptToRun of workerData.scriptsToRun) { - runInThisContext(scriptToRun.code, { - filename: scriptToRun.filename, - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, - }); -} diff --git a/test/fixtures/wpt-backends-spec.js b/test/fixtures/wpt-backends-spec.js new file mode 100644 index 00000000000..19424eddad2 --- /dev/null +++ b/test/fixtures/wpt-backends-spec.js @@ -0,0 +1,24 @@ +'use strict'; + +// Driven through both WPT runner backends by +// test/parallel/test-common-wpt-backends.js. Between them these produce every +// kind of message the two backends have to agree on. + +test(() => {}, 'passes'); + +test(() => { + assert_true(false, 'deliberate failure'); +}, 'fails'); + +test(() => {}, 'skipped by name'); + +test(() => {}, 'skipped by pattern'); + +promise_test(async () => {}, 'passes asynchronously'); + +if (globalThis.WPT_BACKENDS_THROW) { + // Thrown once results have already been reported, which is when the backends + // stop sharing a mechanism: a worker thread surfaces this through its + // 'error' event, a process has to report it before exiting. + throw new Error('deliberate uncaught error'); +} diff --git a/test/parallel/test-common-wpt-any.js b/test/parallel/test-common-wpt-any.js index e6656379991..c198fd70714 100644 --- a/test/parallel/test-common-wpt-any.js +++ b/test/parallel/test-common-wpt-any.js @@ -57,6 +57,10 @@ assert.deepStrictEqual(specs.map((spec) => ({ ]); const runner = new WPTRunner('WebCryptoAPI'); +assert.throws( + () => new WPTRunner('WebCryptoAPI', { concurrency: 0 }), + /WPT concurrency must be a positive integer/, +); runner.pretendGlobalThisAs('Window'); assert.match(runner.fullInitScript(specs[0]), /globalThis\.Window/); assert.doesNotMatch(runner.fullInitScript(specs[1]), /globalThis\.Window/); diff --git a/test/parallel/test-common-wpt-backends.js b/test/parallel/test-common-wpt-backends.js new file mode 100644 index 00000000000..c8c15d84a42 --- /dev/null +++ b/test/parallel/test-common-wpt-backends.js @@ -0,0 +1,184 @@ +'use strict'; + +// The WPT runner can run each spec on a worker thread or in a child process. +// Suites opt into either, and share the status files, so both backends have to +// report the same things in the same way. + +const common = require('../common'); +const fixtures = require('../common/fixtures'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); +const { spawnSync } = require('child_process'); +const { backends, WPTRunner } = require('../common/wpt'); + +const queueProbe = process.env.NODE_TEST_WPT_QUEUE_PROBE === '1'; + +const harnessPath = fixtures.path('wpt', 'resources', 'testharness.js'); +const specPath = fixtures.path('wpt-backends-spec.js'); +const execArgv = []; + +function payload(throws) { + return { + testRelativePath: 'backends.any.js', + wptRunner: path.join(__dirname, '../common/wpt.js'), + wptPath: 'compression', + initScript: throws ? 'globalThis.WPT_BACKENDS_THROW = true;' : null, + harness: { + code: fs.readFileSync(harnessPath, 'utf8'), + filename: harnessPath, + }, + scriptsToRun: [{ + code: fs.readFileSync(specPath, 'utf8'), + filename: specPath, + }], + needsGc: false, + // A regular expression only survives the trip to a child process because + // the runner forks with advanced serialization. + skippedTests: ['skipped by name', /^skipped by pattern$/], + }; +} + +// Collect what a backend reports for one spec, driving it the way the runner +// does so that the real spawn options are exercised. +async function collect(backend, throws) { + const events = []; + let done = false; + + const handle = backends[backend](execArgv, payload(throws), { + message: (message) => { + switch (message.type) { + case 'result': + events.push(`result ${message.result.status} ${message.result.name}`); + break; + case 'skip': + events.push(`skip ${message.name}`); + break; + case 'completion': + events.push(`completion ${message.status.status}`); + done = true; + handle.kill(); + break; + default: + assert.fail(`Unexpected message type: ${message.type}`); + } + }, + failure: (failure) => { + if (done) { + return false; + } + done = true; + events.push(`uncaught ${failure.name} | ${failure.message}`); + return true; + }, + }); + + await handle.finished; + return events; +} + +async function compare(throws) { + const comparable = async (backend) => { + const events = await collect(backend, throws); + // A worker thread keeps delivering messages after it throws, so `events` + // is copied here and only the error is compared; what the spec reports + // before throwing is covered by the run that completes normally. + const wanted = throws ? (event) => event.startsWith('uncaught ') : () => true; + return events.filter(wanted).sort(); + }; + + const thread = await comparable('thread'); + const child = await comparable('process'); + assert.notStrictEqual(thread.length, 0); + assert.deepStrictEqual(thread, child); + return thread; +} + +// End to end: the runner's own reporting has to match too. The webidl spec +// reports an uncaught error whose name the status file matches on. +function runDriver(driver, spec, backend) { + const { status, stdout, stderr } = spawnSync( + process.execPath, + [path.join(__dirname, '../wpt', driver), spec], + { env: { ...process.env, WPT_BACKEND: backend }, encoding: 'utf8' }, + ); + assert.strictEqual(status, 0, `${spec} failed on the ${backend} backend:\n${stdout}${stderr}`); + // Specs run concurrently, so the lines arrive in an arbitrary order. + return stdout.split('\n').filter((line) => line.startsWith('[')).sort(); +} + +function runQueueProbe() { + backends.process = common.mustCall((execArgv, workerData, handlers) => { + queueMicrotask(() => handlers.message({ + type: 'completion', + status: { status: 0 }, + })); + return { + kill() {}, + // Model the gap between a spec completing and its process closing. The + // close notification alone must not be responsible for keeping the + // parent alive long enough to start the next queued spec. + finished: new Promise((resolve) => { + setTimeout(common.mustCall(resolve), 1).unref(); + }), + }; + }, 2); + + process.argv[2] = 'compression-bad-chunks.any.js'; + const runner = new WPTRunner('compression', { + backend: 'process', + concurrency: 1, + }); + // WPT drivers intentionally do not await this method. + runner.runJsTests(); +} + +function checkQueuedSpecsKeepRunnerAlive() { + const result = spawnSync(process.execPath, [__filename], { + env: { + ...process.env, + NODE_TEST_WPT_QUEUE_PROBE: '1', + WPT_BACKEND: 'process', + }, + encoding: 'utf8', + timeout: common.platformTimeout(10_000), + }); + const { error, status, stdout, stderr } = result; + assert.ifError(error); + assert.strictEqual(status, 0, `Queued WPT probe failed:\n${stdout}${stderr}`); +} + +async function main() { + checkQueuedSpecsKeepRunnerAlive(); + + const completed = await compare(false); + assert.deepStrictEqual(completed, [ + 'completion 0', + 'result 0 passes', + 'result 0 passes asynchronously', + 'result 1 fails', + 'skip skipped by name', + 'skip skipped by pattern', + ]); + + const uncaught = await compare(true); + assert.deepStrictEqual(uncaught, [ + 'uncaught Error: deliberate uncaught error | deliberate uncaught error', + ]); + + for (const [driver, spec] of [ + ['test-compression.js', 'compression-bad-chunks.any.js'], + ['test-webidl.js', 'ecmascript-binding/global-object-implicit-this-value.any.js'], + ]) { + assert.deepStrictEqual( + runDriver(driver, spec, 'thread'), + runDriver(driver, spec, 'process'), + ); + } +} + +if (queueProbe) { + runQueueProbe(); +} else { + main().then(common.mustCall()); +} diff --git a/test/wpt/test-compression.js b/test/wpt/test-compression.js index 23800734922..404cb23687c 100644 --- a/test/wpt/test-compression.js +++ b/test/wpt/test-compression.js @@ -2,7 +2,8 @@ const { WPTRunner } = require('../common/wpt'); -const runner = new WPTRunner('compression'); +// Runs each spec in its own process; this suite has crashed the runner in CI. +const runner = new WPTRunner('compression', { backend: 'process' }); runner.pretendGlobalThisAs('Window'); diff --git a/test/wpt/test-streams.js b/test/wpt/test-streams.js index 71c25fbd56b..e9d23348db0 100644 --- a/test/wpt/test-streams.js +++ b/test/wpt/test-streams.js @@ -2,7 +2,8 @@ const { WPTRunner } = require('../common/wpt'); -const runner = new WPTRunner('streams'); +// Runs each spec in its own process; this suite has crashed the runner in CI. +const runner = new WPTRunner('streams', { backend: 'process' }); // Set a script that will be executed in the worker before running the tests. runner.pretendGlobalThisAs('Window'); diff --git a/test/wpt/test-wasm-jsapi.mjs b/test/wpt/test-wasm-jsapi.mjs index 4e53da5bdd8..67050e67cf7 100644 --- a/test/wpt/test-wasm-jsapi.mjs +++ b/test/wpt/test-wasm-jsapi.mjs @@ -15,7 +15,8 @@ try { } if (supportsSimd) { - const runner = new WPTRunner('wasm/jsapi'); + // Runs each spec in its own process; this suite has crashed the runner in CI. + const runner = new WPTRunner('wasm/jsapi', { backend: 'process' }); runner.setFlags(['--experimental-wasm-modules']); runner.runJsTests(); diff --git a/test/wpt/test-webcrypto.js b/test/wpt/test-webcrypto.js index 409b94451ba..a435d429af9 100644 --- a/test/wpt/test-webcrypto.js +++ b/test/wpt/test-webcrypto.js @@ -6,7 +6,8 @@ if (!common.hasCrypto) const { WPTRunner } = require('../common/wpt'); -const runner = new WPTRunner('WebCryptoAPI'); +// Runs each spec in its own process; this suite has crashed the runner in CI. +const runner = new WPTRunner('WebCryptoAPI', { backend: 'process' }); // Experimental warnings drown out the actual test output. runner.setFlags(['--disable-warning=ExperimentalWarning']);