diff options
author | Rich Trott <rtrott@gmail.com> | 2019-06-19 13:10:05 -0600 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-09-08 10:10:38 -0700 |
commit | 2d1b5128d160876b661d83954bdda78da5647e45 (patch) | |
tree | 5ea98abe53d1a51a8210c8ced30d5ebda55438d1 /test/async-hooks | |
parent | e585caa2bebbd238c763af588a40879b61cf240f (diff) | |
download | node-new-2d1b5128d160876b661d83954bdda78da5647e45.tar.gz |
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>
Diffstat (limited to 'test/async-hooks')
-rw-r--r-- | test/async-hooks/test-signalwrap.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js index b906355af7..4584d140ce 100644 --- a/test/async-hooks/test-signalwrap.js +++ b/test/async-hooks/test-signalwrap.js @@ -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'); |