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: fix WPT runner cutting off inprogress workers #47626

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 8 additions & 5 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ class WPTRunner {
);

this.results = {};
this.inProgress = new Set();
this.workers = new Map();
this.unexpectedFailures = [];

Expand Down Expand Up @@ -559,7 +558,7 @@ class WPTRunner {
queue = this.buildQueue();
}

this.inProgress = new Set(queue.map((spec) => spec.filename));
this.inProgress = new Set();

const run = limit(os.availableParallelism());

Expand Down Expand Up @@ -612,6 +611,7 @@ class WPTRunner {
needsGc,
},
});
this.inProgress.add(testFileName);
this.workers.set(testFileName, worker);

let reportResult;
Expand All @@ -621,7 +621,7 @@ class WPTRunner {
reportResult ||= this.report?.addResult(`/${relativePath}${variant}`, 'OK');
return this.resultCallback(testFileName, message.result, reportResult);
case 'completion':
return this.completionCallback(testFileName, message.status);
return this.completionCallback(testFileName, worker, message.status);
default:
throw new Error(`Unexpected message from worker: ${message.type}`);
}
Expand Down Expand Up @@ -661,6 +661,8 @@ class WPTRunner {
}
}

await Promise.all([...this.workers.values()].map((worker) => events.once(worker, 'exit')));

process.on('exit', () => {
if (this.inProgress.size > 0) {
for (const filename of this.inProgress) {
Expand Down Expand Up @@ -784,9 +786,10 @@ class WPTRunner {
* Report the status of each WPT test (one per file)
*
* @param {string} filename
* @param {string} worker - Reference to the worker.
* @param {object} harnessStatus - The status object returned by WPT harness.
*/
completionCallback(filename, harnessStatus) {
completionCallback(filename, worker, harnessStatus) {
// Treat it like a test case failure
if (harnessStatus.status === 2) {
const title = this.getTestTitle(filename);
Expand All @@ -796,7 +799,7 @@ class WPTRunner {
this.inProgress.delete(filename);
// Always force termination of the worker. Some tests allocate resources
// that would otherwise keep it alive.
this.workers.get(filename).terminate();
worker.terminate();
}

addTestResult(filename, item) {
Expand Down