Skip to content

Commit 8c6ae88

Browse files
authored
process-exit-code-cases.js: update zeroExitWithUncaughtHandler and changeCodeInUncaughtHandler
cannot use `node:assert` module in cases where `uncaughtException` handler is registered as an failure will be eaten by it
1 parent 852a1a6 commit 8c6ae88

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/fixtures/process-exit-code-cases.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ function getTestCases(isWorker = false) {
6363

6464
function zeroExitWithUncaughtHandler() {
6565
process.on('exit', (code) => {
66-
assert.strictEqual(process.exitCode, 0);
67-
assert.strictEqual(code, 0);
66+
if (code !== 0) {
67+
console.log('wrong code! expected 0; got', code);
68+
process.exit(99);
69+
}
70+
if (process.exitCode !== undefined) {
71+
console.log('wrong exitCode! expected undefined; got', process.exitCode);
72+
process.exit(99);
73+
}
6874
});
6975
process.on('uncaughtException', () => { });
7076
throw new Error('ok');
@@ -73,8 +79,14 @@ function getTestCases(isWorker = false) {
7379

7480
function changeCodeInUncaughtHandler() {
7581
process.on('exit', (code) => {
76-
assert.strictEqual(process.exitCode, 97);
77-
assert.strictEqual(code, 97);
82+
if (code !== 97) {
83+
console.log('wrong code! expected 97; got', code);
84+
process.exit(99);
85+
}
86+
if (process.exitCode !== 97) {
87+
console.log('wrong exitCode! expected 97; got', process.exitCode);
88+
process.exit(99);
89+
}
7890
});
7991
process.on('uncaughtException', () => {
8092
process.exitCode = 97;

0 commit comments

Comments
 (0)