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: https://github.com/nodejs/node/pull/28306
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Rich Trott 2019-06-19 13:10:05 -06:00
parent e585caa2be
commit 2d1b5128d1

View File

@ -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');