Skip to content

Commit 2e8570b

Browse files
RaisinTenaduh95
authored andcommitted
test: account for truthy signal in flaky async_hooks tests
When the spawned child process gets closed with a signal, the exit code is not set and that is why the exit code assertion was failing. This change adjusts the test to check the signal and if it is truthy, it doesn't assert the exit code and instead logs the signal and continues the rest of the assertions. Refs: #58463 (comment) Refs: #58199 Refs: #58463 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #58478 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 0105c13 commit 2e8570b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

test/async-hooks/test-emit-after-on-destroyed.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ if (process.argv[2] === 'child') {
5252
child.stderr.on('data', (d) => { errData = Buffer.concat([ errData, d ]); });
5353
child.stdout.on('data', (d) => { outData = Buffer.concat([ outData, d ]); });
5454

55-
child.on('close', common.mustCall((code) => {
56-
assert.strictEqual(code, 1);
55+
child.on('close', common.mustCall((code, signal) => {
56+
if (signal) {
57+
console.log(`Child closed with signal: ${signal}`);
58+
} else {
59+
assert.strictEqual(code, 1);
60+
}
5761
assert.match(outData.toString(), heartbeatMsg,
5862
'did not crash until we reached offending line of code ' +
5963
`(found ${outData})`);

test/async-hooks/test-improper-unwind.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ if (process.argv[2] === 'child') {
5555
child.stderr.on('data', (d) => { errData = Buffer.concat([ errData, d ]); });
5656
child.stdout.on('data', (d) => { outData = Buffer.concat([ outData, d ]); });
5757

58-
child.on('close', common.mustCall((code) => {
59-
assert.strictEqual(code, 1);
58+
child.on('close', common.mustCall((code, signal) => {
59+
if (signal) {
60+
console.log(`Child closed with signal: ${signal}`);
61+
} else {
62+
assert.strictEqual(code, 1);
63+
}
6064
assert.match(outData.toString(), heartbeatMsg,
6165
'did not crash until we reached offending line of code ' +
6266
`(found ${outData})`);

0 commit comments

Comments
 (0)