diff options
author | jvelezpo <sebasvelez@gmail.com> | 2018-01-25 14:47:52 -0500 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-02-04 16:38:34 +0100 |
commit | 6f8de31cde682f9d90455433e8ee72fffa27a101 (patch) | |
tree | da12c0d537d892888c84cea91931d848f31794e3 /test | |
parent | 71b15e8c7b935ba58838afdbe3ac114908edcb08 (diff) | |
download | android-node-v8-6f8de31cde682f9d90455433e8ee72fffa27a101.tar.gz android-node-v8-6f8de31cde682f9d90455433e8ee72fffa27a101.tar.bz2 android-node-v8-6f8de31cde682f9d90455433e8ee72fffa27a101.zip |
test: verify the shell option works properly on execFile
Useful for executing in a shell because it accepts arguments as
an array instead of a string as exec does.
Depending on the circumstances,
that can prove to be useful if the arguments are already prepared.
PR-URL: https://github.com/nodejs/node/pull/18384
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-child-process-execfile.js | 8 | ||||
-rw-r--r-- | test/sequential/test-child-process-execsync.js | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-child-process-execfile.js b/test/parallel/test-child-process-execfile.js index 415489e9db..af69d68578 100644 --- a/test/parallel/test-child-process-execfile.js +++ b/test/parallel/test-child-process-execfile.js @@ -7,6 +7,7 @@ const { getSystemErrorName } = require('util'); const fixtures = require('../common/fixtures'); const fixture = fixtures.path('exit.js'); +const execOpts = { encoding: 'utf8', shell: true }; { execFile( @@ -39,3 +40,10 @@ const fixture = fixtures.path('exit.js'); child.kill(); child.emit('close', code, null); } + +{ + // Verify the shell option works properly + execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => { + assert.ifError(err); + })); +} diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index da80e80bce..133217dcdf 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -29,6 +29,7 @@ const TIMER = 200; const SLEEP = 2000; const start = Date.now(); +const execOpts = { encoding: 'utf8', shell: true }; let err; let caught = false; @@ -141,3 +142,8 @@ assert.strictEqual(ret, `${msg}\n`); return true; }); } + +// Verify the shell option works properly +assert.doesNotThrow(() => { + execFileSync(process.execPath, [], execOpts); +}); |