Skip to content

Commit 7419338

Browse files
vsemozhetbytMylesBorins
authored andcommitted
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 ac400a7 commit 7419338

13 files changed

+31
-30
lines changed

test/common/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ exports.childShouldThrowAndAbort = function() {
214214
// continuous testing and developers' machines
215215
testCmd += 'ulimit -c 0 && ';
216216
}
217-
testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
218-
testCmd += `${process.argv[1]} child`;
217+
testCmd += `"${process.argv[0]}" --abort-on-uncaught-exception `;
218+
testCmd += `"${process.argv[1]}" child`;
219219
const child = child_process.exec(testCmd);
220220
child.on('exit', function onExit(exitCode, signal) {
221221
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-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
@@ -199,7 +199,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
199199
// Ensure that arguments are successfully passed to a script.
200200
// The first argument after '--' should be interpreted as a script
201201
// filename.
202-
const filecmd = `${nodejs} -- ${__filename} ${args}`;
202+
const filecmd = `${nodejs} -- "${__filename}" ${args}`;
203203
child.exec(filecmd, common.mustCall(function(err, stdout, stderr) {
204204
assert.strictEqual(stdout, `${args}\n`);
205205
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);

test/parallel/test-http-chunk-problem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ const filename = require('path').join(common.tmpDir, 'big');
4242
let server;
4343

4444
function executeRequest(cb) {
45-
cp.exec([process.execPath,
46-
__filename,
45+
cp.exec([`"${process.execPath}"`,
46+
`"${__filename}"`,
4747
'request',
4848
server.address().port,
4949
'|',
50-
process.execPath,
51-
__filename,
50+
`"${process.execPath}"`,
51+
`"${__filename}"`,
5252
'shasum' ].join(' '),
5353
(err, stdout, stderr) => {
5454
if (err) throw err;

0 commit comments

Comments
 (0)