Skip to content
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
7 changes: 6 additions & 1 deletion lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ function setup(root) {
kCancelledByParent));

hook.disable();
process.removeListener('unhandledRejection', rejectionHandler);
process.removeListener('uncaughtException', exceptionHandler);
process.removeListener('unhandledRejection', rejectionHandler);
process.removeListener('beforeExit', exitHandler);
if (globalOptions.isTestRunner) {
process.removeListener('SIGINT', terminationHandler);
process.removeListener('SIGTERM', terminationHandler);
}
};

const terminationHandler = () => {
Expand Down
5 changes: 4 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ function run(options = kEmptyObject) {
}

let postRun = () => root.postRun();
let teardown = () => root.harness.teardown();
let filesWatcher;
const opts = {
__proto__: null,
Expand All @@ -580,6 +581,7 @@ function run(options = kEmptyObject) {
if (watch) {
filesWatcher = watchFiles(testFiles, opts);
postRun = undefined;
teardown = undefined;
}
const runFiles = () => {
root.harness.bootstrapComplete = true;
Expand All @@ -591,7 +593,8 @@ function run(options = kEmptyObject) {
});
};

PromisePrototypeThen(PromisePrototypeThen(PromiseResolve(setup?.(root.reporter)), runFiles), postRun);
const setupPromise = PromiseResolve(setup?.(root.reporter));
PromisePrototypeThen(PromisePrototypeThen(PromisePrototypeThen(setupPromise, runFiles), postRun), teardown);

return root.reporter;
}
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,13 @@ describe('forceExit', () => {
});
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file still generate a warning when run? If not, we should add an assertion so it doesn't regress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the warning still occurs. I don't think it can be avoided due to the number of tests running in parallel.


// exitHandler doesn't run until after the tests / after hooks finish.
process.on('exit', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about 'beforeExit', 'SIGINT', and 'SIGTERM'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I added checks for those as well.

assert.strictEqual(process.listeners('uncaughtException').length, 0);
assert.strictEqual(process.listeners('unhandledRejection').length, 0);
assert.strictEqual(process.listeners('beforeExit').length, 0);
assert.strictEqual(process.listeners('SIGINT').length, 0);
assert.strictEqual(process.listeners('SIGTERM').length, 0);
});
Loading