diff options
author | Rich Trott <rtrott@gmail.com> | 2017-12-19 22:03:19 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-12-21 10:11:38 -0800 |
commit | ddf3655f2bd2199fa187c56c0bcee419b5a1e1f0 (patch) | |
tree | 2937fd0d819b354310ebfd8a10129fbb37330279 /test | |
parent | fc8e8215f659043bd91c398a516a727e3d662f1b (diff) | |
download | node-new-ddf3655f2bd2199fa187c56c0bcee419b5a1e1f0.tar.gz |
test: remove getTTYfd() from common module
common.getTTYfd() is used in one test only. Move it's definition to that
test and out of the common module.
PR-URL: https://github.com/nodejs/node/pull/17781
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/common/index.js | 17 | ||||
-rw-r--r-- | test/sequential/test-async-wrap-getasyncid.js | 19 |
2 files changed, 18 insertions, 18 deletions
diff --git a/test/common/index.js b/test/common/index.js index b67b2f7b71..07ef0e65b8 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -823,23 +823,6 @@ exports.crashOnUnhandledRejection = function() { (err) => process.nextTick(() => { throw err; })); }; -exports.getTTYfd = function getTTYfd() { - const tty = require('tty'); - let tty_fd = 0; - if (!tty.isatty(tty_fd)) tty_fd++; - else if (!tty.isatty(tty_fd)) tty_fd++; - else if (!tty.isatty(tty_fd)) tty_fd++; - else { - try { - tty_fd = fs.openSync('/dev/tty'); - } catch (e) { - // There aren't any tty fd's available to use. - return -1; - } - } - return tty_fd; -}; - // Hijack stdout and stderr const stdWrite = {}; function hijackStdWritable(name, listener) { diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index bd2b3254f0..2963992c7c 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -247,7 +247,24 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check { // Do our best to grab a tty fd. - const tty_fd = common.getTTYfd(); + function getTTYfd() { + const tty = require('tty'); + let tty_fd = 0; + if (!tty.isatty(tty_fd)) tty_fd++; + else if (!tty.isatty(tty_fd)) tty_fd++; + else if (!tty.isatty(tty_fd)) tty_fd++; + else { + try { + tty_fd = fs.openSync('/dev/tty'); + } catch (e) { + // There aren't any tty fd's available to use. + return -1; + } + } + return tty_fd; + } + + const tty_fd = getTTYfd(); if (tty_fd >= 0) { const tty_wrap = process.binding('tty_wrap'); // fd may still be invalid, so guard against it. |