summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-05-09 20:42:31 +0200
committerRich Trott <rtrott@gmail.com>2018-12-04 13:08:54 -0800
commitab6c09b177eca67755a4c1f1d4d35fab9d2bb5d4 (patch)
tree9086836cb18a09beeacc663387ab2c30b649824d /test
parent54f8453ea1211e1a11280e337ffdfdb7bc8f4ff1 (diff)
downloadandroid-node-v8-ab6c09b177eca67755a4c1f1d4d35fab9d2bb5d4.tar.gz
android-node-v8-ab6c09b177eca67755a4c1f1d4d35fab9d2bb5d4.tar.bz2
android-node-v8-ab6c09b177eca67755a4c1f1d4d35fab9d2bb5d4.zip
process: provide dummy stdio for non-console Windows apps
The only known condition where we could not provide appropriate stdio streams so far were non-console Windows applications. Since this issue has come up a few times in our issue tracker now, switch to providing dummy streams for these cases instead. If there are other valid cases in which `uv_guess_handle` fails, and where there is a more sensible way to provide stdio, we’ll probably still find out because the streams don’t work properly either way. Refs: https://github.com/nodejs/help/issues/1251 PR-URL: https://github.com/nodejs/node/pull/20640 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-dummy-stdio.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-dummy-stdio.js b/test/parallel/test-dummy-stdio.js
new file mode 100644
index 0000000000..165c2c2c57
--- /dev/null
+++ b/test/parallel/test-dummy-stdio.js
@@ -0,0 +1,27 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const child_process = require('child_process');
+
+if (common.isWindows)
+ common.skip('fs.closeSync(n) does not close stdio on Windows');
+
+function runTest(fd, streamName, testOutputStream, expectedName) {
+ const result = child_process.spawnSync(process.execPath, [
+ '--expose-internals',
+ '-e', `
+ require('internal/process/stdio').resetStdioForTesting();
+ fs.closeSync(${fd});
+ const ctorName = process.${streamName}.constructor.name;
+ process.${testOutputStream}.write(ctorName);
+ `]);
+ assert.strictEqual(result[testOutputStream].toString(), expectedName,
+ `stdout:\n${result.stdout}\nstderr:\n${result.stderr}\n` +
+ `while running test with fd = ${fd}`);
+ if (testOutputStream !== 'stderr')
+ assert.strictEqual(result.stderr.toString(), '');
+}
+
+runTest(0, 'stdin', 'stdout', 'Readable');
+runTest(1, 'stdout', 'stderr', 'Writable');
+runTest(2, 'stderr', 'stdout', 'Writable');