Skip to content

Commit

Permalink
fix issue found in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jul 3, 2022
1 parent db19e9a commit 7bf3ba6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ function setup(root) {
}
};

const terminationHandler = () => {
exitHandler();
process.exit();
}

process.on('uncaughtException', exceptionHandler);
process.on('unhandledRejection', rejectionHandler);
process.on('beforeExit', exitHandler);
process.on('SIGINT', exitHandler);
process.on('SIGTERM', exitHandler);
process.on('SIGINT', terminationHandler);
process.on('SIGTERM', terminationHandler);

root.reporter.pipe(process.stdout);
root.reporter.version();
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-runner-exit-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { setTimeout } = require('timers/promises');

if (process.argv[2] === 'child') {
const test = require('node:test');
Expand All @@ -18,7 +19,7 @@ if (process.argv[2] === 'child') {
} else if (process.argv[3] === 'never_ends') {
assert.strictEqual(process.argv[3], 'never_ends');
test('never ending test', () => {
return new Promise(() => {});
return setTimeout(100_000_000);
});
process.kill(process.pid, 'SIGINT');
}
Expand Down

0 comments on commit 7bf3ba6

Please sign in to comment.