Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd996bf

Browse files
nektromarco-ippolito
authored andcommitted
test: do not swallow uncaughtException errors in exit code tests
PR-URL:#54039Reviewed-By: Rich Trott <rtrott@gmail.com>Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent2a3ae16 commitbd996bf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎test/common/process-exit-code-cases.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,25 @@ function getTestCases(isWorker = false) {
6262
cases.push({func:changeCodeInsideExit,result:99});
6363

6464
functionzeroExitWithUncaughtHandler(){
65+
constnoop=()=>{};
6566
process.on('exit',(code)=>{
66-
assert.strictEqual(process.exitCode,0);
67+
process.off('uncaughtException',noop);
68+
assert.strictEqual(process.exitCode,undefined);
6769
assert.strictEqual(code,0);
6870
});
69-
process.on('uncaughtException',()=>{});
71+
process.on('uncaughtException',noop);
7072
thrownewError('ok');
7173
}
7274
cases.push({func:zeroExitWithUncaughtHandler,result:0});
7375

7476
functionchangeCodeInUncaughtHandler(){
77+
constmodifyExitCode=()=>{process.exitCode=97;};
7578
process.on('exit',(code)=>{
79+
process.off('uncaughtException',modifyExitCode);
7680
assert.strictEqual(process.exitCode,97);
7781
assert.strictEqual(code,97);
7882
});
79-
process.on('uncaughtException',()=>{
80-
process.exitCode=97;
81-
});
83+
process.on('uncaughtException',modifyExitCode);
8284
thrownewError('ok');
8385
}
8486
cases.push({func:changeCodeInUncaughtHandler,result:97});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp