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: #12972Fixes: #12773 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent ac400a7 commit 7419338

13 files changed

Lines changed: 31 additions & 30 deletions

‎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
constchild=child_process.exec(testCmd);
220220
child.on('exit',functiononExit(exitCode,signal){
221221
consterrMsg='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
constbigNum=Math.pow(2,exponent);
2020
constlongLine=lineSeed.repeat(bigNum);
21-
constcmd=`${process.execPath}${__filename} child ${exponent}${bigNum}`;
21+
constcmd=
22+
`"${process.execPath}" "${__filename}" child ${exponent}${bigNum}`;
2223
conststdout=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
functioncreateChild(options,callback){
30-
constcmd=`${process.execPath}${__filename} child`;
30+
constcmd=`"${process.execPath}" "${__filename}" child`;
3131

3232
returncp.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
functionrun(options,callback){
16-
constcmd=`${process.execPath}${__filename} child`;
16+
constcmd=`"${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-
constcmd=`${process.execPath}${__filename} child`;
15+
constcmd=`"${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-
constfilecmd=`${nodejs} -- ${__filename}${args}`;
202+
constfilecmd=`${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
returntestCmd;
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
constchild=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
functiontest(env){
10-
constcmd=`${process.execPath}${__filename} child`;
10+
constcmd=`"${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
letserver;
4343

4444
functionexecuteRequest(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)throwerr;

0 commit comments

Comments
 (0)