diff --git a/test/common/index.js b/test/common/index.js index 0fd42aa04b1eea..0e40d0be215cb8 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -770,23 +770,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 1744831ca3be12..e1cc38ab7bbef7 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -256,7 +256,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.