aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-console.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-22 09:17:19 -0700
committerJames M Snell <jasnell@gmail.com>2018-08-24 09:53:58 -0700
commit5da834f685f85af477afcb193d283f14a5244025 (patch)
tree1d86045f11e1cad9622be34a8a907b4972493624 /test/parallel/test-console.js
parentea8b932f30665436796c7e5abd485f048a0f41c8 (diff)
downloadandroid-node-v8-5da834f685f85af477afcb193d283f14a5244025.tar.gz
android-node-v8-5da834f685f85af477afcb193d283f14a5244025.tar.bz2
android-node-v8-5da834f685f85af477afcb193d283f14a5244025.zip
test: move hijackstdio out of require('common')
Move the hijackstdio functions out of common so that they are imported only into the tests that actually need them PR-URL: https://github.com/nodejs/node/pull/22462 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-console.js')
-rw-r--r--test/parallel/test-console.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js
index d6064016b5..21fbeed929 100644
--- a/test/parallel/test-console.js
+++ b/test/parallel/test-console.js
@@ -24,6 +24,13 @@ const common = require('../common');
const assert = require('assert');
const util = require('util');
+const {
+ hijackStdout,
+ hijackStderr,
+ restoreStdout,
+ restoreStderr
+} = require('../common/hijackstdio');
+
assert.ok(process.stdout.writable);
assert.ok(process.stderr.writable);
// Support legacy API
@@ -63,11 +70,11 @@ const custom_inspect = { foo: 'bar', [util.inspect.custom]: () => 'inspect' };
const strings = [];
const errStrings = [];
process.stdout.isTTY = false;
-common.hijackStdout(function(data) {
+hijackStdout(function(data) {
strings.push(data);
});
process.stderr.isTTY = false;
-common.hijackStderr(function(data) {
+hijackStderr(function(data) {
errStrings.push(data);
});
@@ -175,8 +182,8 @@ console.assert(true, 'this should not throw');
assert.strictEqual(strings.length, process.stdout.writeTimes);
assert.strictEqual(errStrings.length, process.stderr.writeTimes);
-common.restoreStdout();
-common.restoreStderr();
+restoreStdout();
+restoreStderr();
// verify that console.timeEnd() doesn't leave dead links
const timesMapSize = console._times.size;
@@ -246,8 +253,8 @@ assert.strictEqual(errStrings.shift().split('\n').shift(),
// hijack stderr to catch `process.emitWarning` which is using
// `process.nextTick`
-common.hijackStderr(common.mustCall(function(data) {
- common.restoreStderr();
+hijackStderr(common.mustCall(function(data) {
+ restoreStderr();
// stderr.write will catch sync error, so use `process.nextTick` here
process.nextTick(function() {