(url, options, expectation, timeout = 10000)
| 331 | } |
| 332 | |
| 333 | function runSingleTest (url, options, expectation, timeout = 10000) { |
| 334 | const startTime = Date.now() |
| 335 | const { promise, resolve, reject } = Promise.withResolvers() |
| 336 | // NODE_EXTRA_CA_CERTS is required for HTTPS/WSS pages, but it causes the |
| 337 | // WebSocket-over-HTTP/2 WPT variants to exit without emitting harness output. |
| 338 | const useExtraCACerts = !(url.pathname.startsWith('/websockets/') && url.searchParams.get('wpt_flags')?.includes('h2')) |
| 339 | |
| 340 | const proc = spawn('node', [ |
| 341 | '--expose-gc', |
| 342 | '--no-warnings', |
| 343 | join(import.meta.dirname, 'runner/test-runner.mjs'), |
| 344 | url.toString() |
| 345 | ], { |
| 346 | stdio: ['ignore', 'pipe', 'pipe'], |
| 347 | env: { |
| 348 | ...process.env, |
| 349 | NO_COLOR: '1', |
| 350 | ...(useExtraCACerts ? { NODE_EXTRA_CA_CERTS: CA_CERT_PATH } : {}) |
| 351 | } |
| 352 | }) |
| 353 | |
| 354 | const cases = [] |
| 355 | let harnessStatus = null |
| 356 | let stdoutOutput = '' |
| 357 | let stderrOutput = '' |
| 358 | let error |
| 359 | |
| 360 | const timer = setTimeout(() => { |
| 361 | if (!proc.killed) { |
| 362 | proc.kill('SIGINT') |
| 363 | } |
| 364 | }, timeout) |
| 365 | |
| 366 | proc.stdout.setEncoding('utf-8') |
| 367 | proc.stdout.on('data', (chunk) => { |
| 368 | stdoutOutput += chunk |
| 369 | |
| 370 | let delimiterIndex |
| 371 | while ((delimiterIndex = stdoutOutput.indexOf('#$#$#')) !== -1) { |
| 372 | const endIndex = stdoutOutput.indexOf('\n', delimiterIndex) |
| 373 | if (endIndex !== -1) { |
| 374 | const message = stdoutOutput.slice(delimiterIndex + 5, endIndex) |
| 375 | try { |
| 376 | const { tests, harnessStatus: _harnessStatus } = JSON.parse(message) |
| 377 | harnessStatus = _harnessStatus |
| 378 | cases.push(...tests) |
| 379 | } catch { |
| 380 | console.error('Failed to parse:', message) |
| 381 | } |
| 382 | stdoutOutput = stdoutOutput.slice(endIndex + 1) |
| 383 | } else { |
| 384 | break |
| 385 | } |
| 386 | } |
| 387 | }) |
| 388 | |
| 389 | proc.stderr.setEncoding('utf-8') |
| 390 | proc.stderr.on('data', (chunk) => { |
no test coverage detected
searching dependent graphs…