aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-spawnsync-shell.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2017-06-10 14:15:51 -0400
committerBrian White <mscdex@mscdex.net>2017-06-13 19:19:16 -0400
commit448c4c62d2b413226dfdef03d6f8d243de0984a3 (patch)
tree5868b23249b4f36a5debb3e2abe448b28c932519 /test/parallel/test-child-process-spawnsync-shell.js
parent9dc3f936c78621c0e1781f65b336bff920187a82 (diff)
downloadandroid-node-v8-448c4c62d2b413226dfdef03d6f8d243de0984a3.tar.gz
android-node-v8-448c4c62d2b413226dfdef03d6f8d243de0984a3.tar.bz2
android-node-v8-448c4c62d2b413226dfdef03d6f8d243de0984a3.zip
child_process: do not extend result for *Sync()
PR-URL: https://github.com/nodejs/node/pull/13601 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-spawnsync-shell.js')
-rw-r--r--test/parallel/test-child-process-spawnsync-shell.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/test/parallel/test-child-process-spawnsync-shell.js b/test/parallel/test-child-process-spawnsync-shell.js
index 9e03ee126f..ed66d79332 100644
--- a/test/parallel/test-child-process-spawnsync-shell.js
+++ b/test/parallel/test-child-process-spawnsync-shell.js
@@ -1,7 +1,10 @@
+// Flags: --expose_internals
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
+const internalCp = require('internal/child_process');
+const oldSpawnSync = internalCp.spawnSync;
// Verify that a shell is, in fact, executed
const doesNotExist = cp.spawnSync('does-not-exist', {shell: true});
@@ -16,10 +19,14 @@ else
assert.strictEqual(doesNotExist.status, 127); // Exit code of /bin/sh
// Verify that passing arguments works
+internalCp.spawnSync = common.mustCall(function(opts) {
+ assert.strictEqual(opts.args[opts.args.length - 1].replace(/"/g, ''),
+ 'echo foo');
+ return oldSpawnSync(opts);
+});
const echo = cp.spawnSync('echo', ['foo'], {shell: true});
+internalCp.spawnSync = oldSpawnSync;
-assert.strictEqual(echo.args[echo.args.length - 1].replace(/"/g, ''),
- 'echo foo');
assert.strictEqual(echo.stdout.toString().trim(), 'foo');
// Verify that shell features can be used
@@ -52,16 +59,18 @@ assert.strictEqual(env.stdout.toString().trim(), 'buzz');
const shellFlags = platform === 'win32' ? ['/d', '/s', '/c'] : ['-c'];
const outputCmd = platform === 'win32' ? `"${cmd}"` : cmd;
const windowsVerbatim = platform === 'win32' ? true : undefined;
- const result = cp.spawnSync(cmd, { shell });
-
- assert.strictEqual(result.file, shellOutput);
- assert.deepStrictEqual(result.args,
- [shellOutput, ...shellFlags, outputCmd]);
- assert.strictEqual(result.options.shell, shell);
- assert.strictEqual(result.options.file, result.file);
- assert.deepStrictEqual(result.options.args, result.args);
- assert.strictEqual(result.options.windowsVerbatimArguments,
- windowsVerbatim);
+ internalCp.spawnSync = common.mustCall(function(opts) {
+ assert.strictEqual(opts.file, shellOutput);
+ assert.deepStrictEqual(opts.args,
+ [shellOutput, ...shellFlags, outputCmd]);
+ assert.strictEqual(opts.options.shell, shell);
+ assert.strictEqual(opts.options.file, opts.file);
+ assert.deepStrictEqual(opts.options.args, opts.args);
+ assert.strictEqual(opts.options.windowsVerbatimArguments,
+ windowsVerbatim);
+ });
+ cp.spawnSync(cmd, { shell });
+ internalCp.spawnSync = oldSpawnSync;
}
// Test Unix platforms with the default shell.