Skip to content

Commit 945f208

Browse files
committed
test: make the rest of tests path-independent
Permit spaces in paths to a Node.js executable and test scripts. PR-URL: #12972 Fixes: #12773 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 9516aa1 commit 945f208

14 files changed

+32
-31
lines changed

test/common/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ exports.childShouldThrowAndAbort = function() {
285285
// continuous testing and developers' machines
286286
testCmd += 'ulimit -c 0 && ';
287287
}
288-
testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
289-
testCmd += `${process.argv[1]} child`;
288+
testCmd += `"${process.argv[0]}" --abort-on-uncaught-exception `;
289+
testCmd += `"${process.argv[1]}" child`;
290290
const child = child_process.exec(testCmd);
291291
child.on('exit', function onExit(exitCode, signal) {
292292
const errMsg = 'Test should have aborted ' +

test/known_issues/test-stdout-buffer-flush-on-exit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ if (process.argv[2] === 'child') {
1818
[22, 21, 20, 19, 18, 17, 16, 16, 17, 18, 19, 20, 21, 22].forEach((exponent) => {
1919
const bigNum = Math.pow(2, exponent);
2020
const longLine = lineSeed.repeat(bigNum);
21-
const cmd = `${process.execPath} ${__filename} child ${exponent} ${bigNum}`;
21+
const cmd =
22+
`"${process.execPath}" "${__filename}" child ${exponent} ${bigNum}`;
2223
const stdout = execSync(cmd).toString().trim();
2324

2425
assert.strictEqual(stdout, longLine, `failed with exponent ${exponent}`);

test/parallel/test-child-process-bad-stdio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ChildProcess.prototype.spawn = function() {
2727
};
2828

2929
function createChild(options, callback) {
30-
const cmd = `${process.execPath} ${__filename} child`;
30+
const cmd = `"${process.execPath}" "${__filename}" child`;
3131

3232
return cp.exec(cmd, options, common.mustCall(callback));
3333
}

test/parallel/test-child-process-exec-encoding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (process.argv[2] === 'child') {
1313
console.error(stderrData);
1414
} else {
1515
function run(options, callback) {
16-
const cmd = `${process.execPath} ${__filename} child`;
16+
const cmd = `"${process.execPath}" "${__filename}" child`;
1717

1818
cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => {
1919
assert.ifError(err);

test/parallel/test-child-process-exec-kill-throws.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (process.argv[2] === 'child') {
1818
throw new Error('mock error');
1919
};
2020

21-
const cmd = `${process.execPath} ${__filename} child`;
21+
const cmd = `"${process.execPath}" "${__filename}" child`;
2222
const options = { maxBuffer: 0 };
2323
const child = cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => {
2424
// Verify that if ChildProcess#kill() throws, the error is reported.

test/parallel/test-child-process-exec-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (process.argv[2] === 'child') {
1212
return;
1313
}
1414

15-
const cmd = `${process.execPath} ${__filename} child`;
15+
const cmd = `"${process.execPath}" "${__filename}" child`;
1616

1717
// Test the case where a timeout is set, and it expires.
1818
cp.exec(cmd, { timeout: 1 }, common.mustCall((err, stdout, stderr) => {

test/parallel/test-cli-eval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
220220
// Ensure that arguments are successfully passed to a script.
221221
// The first argument after '--' should be interpreted as a script
222222
// filename.
223-
const filecmd = `${nodejs} -- ${__filename} ${args}`;
223+
const filecmd = `${nodejs} -- "${__filename}" ${args}`;
224224
child.exec(filecmd, common.mustCall(function(err, stdout, stderr) {
225225
assert.strictEqual(stdout, `${args}\n`);
226226
assert.strictEqual(stderr, '');

test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ function createTestCmdLine(options) {
9090
testCmd += 'ulimit -c 0 && ';
9191
}
9292

93-
testCmd += process.argv[0];
93+
testCmd += `"${process.argv[0]}"`;
9494

9595
if (options && options.withAbortOnUncaughtException) {
9696
testCmd += ' --abort-on-uncaught-exception';
9797
}
9898

99-
testCmd += ` ${process.argv[1]} child`;
99+
testCmd += ` "${process.argv[1]}" child`;
100100

101101
return testCmd;
102102
}

test/parallel/test-domain-with-abort-on-uncaught-exception.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ if (process.argv[2] === 'child') {
103103
if (options.useTryCatch)
104104
useTryCatchOpt = 'useTryCatch';
105105

106-
cmdToExec += `${process.argv[0]} ${cmdLineOption ? cmdLineOption : ''} ${
107-
process.argv[1]} child ${throwInDomainErrHandlerOpt} ${useTryCatchOpt}`;
106+
cmdToExec += `"${process.argv[0]}" ${cmdLineOption ? cmdLineOption : ''} "${
107+
process.argv[1]}" child ${throwInDomainErrHandlerOpt} ${useTryCatchOpt}`;
108108

109109
const child = exec(cmdToExec);
110110

test/parallel/test-env-var-no-warnings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (process.argv[2] === 'child') {
77
process.emitWarning('foo');
88
} else {
99
function test(env) {
10-
const cmd = `${process.execPath} ${__filename} child`;
10+
const cmd = `"${process.execPath}" "${__filename}" child`;
1111

1212
cp.exec(cmd, { env }, common.mustCall((err, stdout, stderr) => {
1313
assert.strictEqual(err, null);

0 commit comments

Comments
 (0)