From 1344ced539ef9f40e33b4e9ab68737e3ec310a48 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 10 Mar 2017 22:40:06 -0800 Subject: [PATCH] test: add coverage for child_process bounds check Make sure that monkey-patching process.execArgv doesn't cause child_process to incorrectly munge execArgv in fork(). This basically is adding coverage for an `index > 0` check (see Refs). Previously, that condition was never false in any of the tests. PR-URL: https://github.com/nodejs/node/pull/11800 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Yuta Hiroto Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76 --- test/parallel/test-cli-eval.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 3eb821958539af..4448e55ca0325c 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -117,6 +117,17 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`, assert.strictEqual(stdout, ''); assert.strictEqual(stderr, ''); })); + + // Make sure that monkey-patching process.execArgv doesn't cause child_process + // to incorrectly munge execArgv. + child.exec( + `${nodejs} -e "process.execArgv = ['-e', 'console.log(42)', 'thirdArg'];` + + `require('child_process').fork('${emptyFile}')"`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, '42\n'); + assert.strictEqual(stderr, ''); + })); } // Regression test for https://github.com/nodejs/node/issues/8534.