Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(wpt): handle uncaught exceptions #1965

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion test/wpt/runner/runner/runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class WPTRunner extends EventEmitter {
/** Tests that have expectedly failed mapped by file name */
#statusOutput = {}

#uncaughtExceptions = []

#stats = {
completed: 0,
failed: 0,
Expand Down Expand Up @@ -58,6 +60,13 @@ export class WPTRunner extends EventEmitter {
this.emit('completion')
})
}

this.once('completion', () => {
for (const exception of this.#uncaughtExceptions) {
console.log(colors(`Uncaught exception: ${exception.stack}`, 'red'))
console.log('='.repeat(96))
}
})
}

static walk (dir, fn) {
Expand Down Expand Up @@ -148,6 +157,10 @@ export class WPTRunner extends EventEmitter {
this.handleIndividualTestCompletion(message, status, test)
} else if (message.type === 'completion') {
this.handleTestCompletion(worker)
} else if (message.type === 'error') {
this.#uncaughtExceptions.push(message.error)
this.#stats.failed += 1
this.#stats.success -= 1
}
})

Expand Down Expand Up @@ -196,7 +209,7 @@ export class WPTRunner extends EventEmitter {
if (!file.allowUnexpectedFailures && !topLevel.allowUnexpectedFailures) {
if (Array.isArray(file.fail)) {
this.#statusOutput[path] ??= []
this.#statusOutput[path].push(file.fail)
this.#statusOutput[path].push(name)
}
}

Expand Down
11 changes: 11 additions & 0 deletions test/wpt/runner/runner/worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ import { CloseEvent } from '../../../../lib/websocket/events.js'

const { initScripts, meta, test, url, path } = workerData

process.on('uncaughtException', (err) => {
parentPort.postMessage({
type: 'error',
error: {
message: err.message,
name: err.name,
stack: err.stack
}
})
})

const basePath = join(process.cwd(), 'test/wpt/tests')
const urlPath = path.slice(basePath.length)

Expand Down
1 change: 1 addition & 0 deletions test/wpt/tests/fetch/api/abort/general.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ promise_test(async t => {
const fetchPromise = fetch('../resources/empty.txt', {
body, signal,
method: 'POST',
duplex: 'half',
headers: {
'Content-Type': 'text/plain'
}
Expand Down