Skip to content

Commit 0d7692f

Browse files
committed
test_runner: handle process exit events in harness and global setup
1 parent d01db08 commit 0d7692f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/internal/test_runner/harness.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ function setupProcessState(root, globalOptions) {
265265
process.removeListener('uncaughtException', exceptionHandler);
266266
process.removeListener('unhandledRejection', rejectionHandler);
267267
process.removeListener('beforeExit', exitHandler);
268+
process.removeListener('exit', exitHandler);
268269
if (globalOptions.isTestRunner) {
269270
process.removeListener('SIGINT', terminationHandler);
270271
process.removeListener('SIGTERM', terminationHandler);
@@ -279,6 +280,7 @@ function setupProcessState(root, globalOptions) {
279280
process.on('uncaughtException', exceptionHandler);
280281
process.on('unhandledRejection', rejectionHandler);
281282
process.on('beforeExit', exitHandler);
283+
process.on('exit', terminationHandler);
282284
// TODO(MoLow): Make it configurable to hook when isTestRunner === false.
283285
if (globalOptions.isTestRunner) {
284286
process.on('SIGINT', terminationHandler);

test/parallel/test-runner-global-setup-watch-mode.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function globalSetup({ context }) {
3030
console.log('Global setup executed');
3131
process.on('message', (message) => {
3232
if (message === 'exit') {
33-
process.kill(process.pid, 'SIGINT');
33+
process.exit(0);
3434
}
3535
});
3636
}

0 commit comments

Comments
 (0)