Skip to content

Commit

Permalink
test: permit test-signalwrap to work without test runner
Browse files Browse the repository at this point in the history
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 <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
Trott authored and BridgeAR committed Sep 25, 2019
1 parent 6a7d24b commit 561d504
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/async-hooks/test-signalwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ function onsigusr2() {
process.on('SIGUSR2', common.mustCall(onsigusr2Again));

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

0 comments on commit 561d504

Please sign in to comment.