diff --git a/test/wpt/runner/runner/runner.mjs b/test/wpt/runner/runner/runner.mjs index 744f89975ba..6e8bebb2460 100644 --- a/test/wpt/runner/runner/runner.mjs +++ b/test/wpt/runner/runner/runner.mjs @@ -1,11 +1,10 @@ import { deepStrictEqual } from 'node:assert' import { EventEmitter, once } from 'node:events' import { readdirSync, readFileSync, statSync } from 'node:fs' -import { cpus } from 'node:os' import { basename, isAbsolute, join, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { Worker } from 'node:worker_threads' -import { parseMeta, handlePipes, normalizeName } from './util.mjs' +import { parseMeta, handlePipes, normalizeName, colors } from './util.mjs' const basePath = fileURLToPath(join(import.meta.url, '../../..')) const testPath = join(basePath, 'tests') @@ -80,14 +79,14 @@ export class WPTRunner extends EventEmitter { } } - return [...files] + return [...files].sort() } async run () { const workerPath = fileURLToPath(join(import.meta.url, '../worker.mjs')) /** @type {Set} */ const activeWorkers = new Set() - let finishedFiles = 0 + let finishedFiles = 1 for (const test of this.#files) { const code = test.includes('.sub.') @@ -97,10 +96,17 @@ export class WPTRunner extends EventEmitter { if (this.#status[basename(test)]?.skip) { this.#stats.skipped += 1 + + console.log('='.repeat(96)) + console.log(colors(`[${finishedFiles}/${this.#files.length}] SKIPPED - ${test}`, 'yellow')) + console.log('='.repeat(96)) + finishedFiles++ continue } + const start = performance.now() + const worker = new Worker(workerPath, { workerData: { // Code to load before the test harness and tests. @@ -126,20 +132,26 @@ export class WPTRunner extends EventEmitter { } }) - worker.once('exit', () => { + try { activeWorkers.delete(worker) - if (++finishedFiles === this.#files.length) { - this.handleRunnerCompletion() - } - }) - - if (activeWorkers.size >= cpus().length) { await once(worker, 'exit', { signal: AbortSignal.timeout(timeout) }) + + console.log('='.repeat(96)) + console.log(colors(`[${finishedFiles}/${this.#files.length}] PASSED - ${test}`, 'green')) + console.log(`Test took ${(performance.now() - start).toFixed(2)}ms`) + console.log('='.repeat(96)) + + finishedFiles++ + } catch (e) { + console.log(`${test} timed out after ${timeout}ms`) + throw e } } + + this.handleRunnerCompletion() } /** diff --git a/test/wpt/runner/runner/util.mjs b/test/wpt/runner/runner/util.mjs index c45fdc1df44..1d75029b6dc 100644 --- a/test/wpt/runner/runner/util.mjs +++ b/test/wpt/runner/runner/util.mjs @@ -1,5 +1,7 @@ +import assert from 'node:assert' import { exit } from 'node:process' import { inspect } from 'node:util' +import tty from 'node:tty' /** * Parse the `Meta:` tags sometimes included in tests. @@ -132,3 +134,15 @@ export function normalizeName (name) { } }) } + +export function colors (str, color) { + assert(Object.hasOwn(inspect.colors, color), `Missing color ${color}`) + + if (!tty.WriteStream.prototype.hasColors()) { + return str + } + + const [start, end] = inspect.colors[color] + + return `\u001b[${start}m${str}\u001b[${end}m` +} diff --git a/test/wpt/start-websockets.mjs b/test/wpt/start-websockets.mjs index 9fe485bb1c1..a8c1067ca5a 100644 --- a/test/wpt/start-websockets.mjs +++ b/test/wpt/start-websockets.mjs @@ -6,7 +6,7 @@ import { on } from 'events' if (process.env.CI) { // TODO(@KhafraDev): figure out *why* these tests are flaky in the CI. - process.exit(0) + // process.exit(0) } const serverPath = fileURLToPath(join(import.meta.url, '../server/websocket.mjs'))