Skip to content

Commit 561d504

Browse files
TrottBridgeAR
authored andcommitted
test: permit test-signalwrap to work without test runner
test/async-hooks/test-signalwrap.js passes with the test.py test runner but fails if run directly with the `node` executable. Modify the test so it passes in both cases. PR-URL: #28306 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 6a7d24b commit 561d504

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/async-hooks/test-signalwrap.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ function onsigusr2() {
5555
process.on('SIGUSR2', common.mustCall(onsigusr2Again));
5656

5757
const as = hooks.activitiesOfTypes('SIGNALWRAP');
58-
assert.strictEqual(as.length, 2);
59-
signal2 = as[1];
58+
// The isTTY checks are needed to allow test to work whether run with
59+
// test.py or directly with the node executable. The third signal event
60+
// listener is the SIGWINCH handler that node installs when it thinks
61+
// process.stdout is a tty.
62+
const expectedLen = 2 + (!!process.stdout.isTTY || !!process.stderr.isTTY);
63+
assert.strictEqual(as.length, expectedLen);
64+
signal2 = as[expectedLen - 1]; // Last item in the array.
6065
assert.strictEqual(signal2.type, 'SIGNALWRAP');
6166
assert.strictEqual(typeof signal2.uid, 'number');
6267
assert.strictEqual(typeof signal2.triggerAsyncId, 'number');

0 commit comments

Comments
 (0)