Skip to content

Commit

Permalink
test: fix ext commands to be double quoted
Browse files Browse the repository at this point in the history
Paths used on the Windows command line need to be enclosed in double
quotes, or they'll be parsed incorrectly when there are spaces in the
path.

PR-URL: #1122
Reviewed-by: Bert Belder <[email protected]>
  • Loading branch information
Shigeki Ohtsu authored and piscisaureus committed Mar 13, 2015
1 parent 5ecdc03 commit 82f067e
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var exec = require('child_process').exec;
var success_count = 0;
var error_count = 0;

var cmd = [process.execPath, '-e', '"console.error(process.argv)"',
var cmd = ['"' + process.execPath + '"', '-e', '"console.error(process.argv)"',
'foo', 'bar'].join(' ');
var expected = util.format([process.execPath, 'foo', 'bar']) + '\n';
var child = exec(cmd, function(err, stdout, stderr) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-readfile-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var callbacks = 0;

function test(env, cb) {
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
var execPath = process.execPath + ' ' + filename;
var execPath = '"' + process.execPath + '" "' + filename + '"';
var options = { env: env || {} };
exec(execPath, options, function(err, stdout, stderr) {
assert(err);
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-http-curl-chunk-problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var count = 0;
function maybeMakeRequest() {
if (++count < 2) return;
console.log('making curl request');
var cmd = 'curl http://127.0.0.1:' + common.PORT + '/ | ' + common.opensslCli + ' sha1';
var cmd = 'curl http://127.0.0.1:' + common.PORT + '/ | ' +
'"' + common.opensslCli + '" sha1';
cp.exec(cmd, function(err, stdout, stderr) {
if (err) throw err;
var hex = stdout.match(/([A-Fa-f0-9]{40})/)[0];
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-ecdh-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var server = tls.createServer(options, function(conn) {
});

server.listen(common.PORT, '127.0.0.1', function() {
var cmd = common.opensslCli + ' s_client -cipher ' + options.ciphers +
var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
' -connect 127.0.0.1:' + common.PORT;

exec(cmd, function(err, stdout, stderr) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-ecdh.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var server = tls.createServer(options, function(conn) {
});

server.listen(common.PORT, '127.0.0.1', function() {
var cmd = common.opensslCli + ' s_client -cipher ' + options.ciphers +
var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
' -connect 127.0.0.1:' + common.PORT;

exec(cmd, function(err, stdout, stderr) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-set-ciphers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var server = tls.createServer(options, function(conn) {
});

server.listen(common.PORT, '127.0.0.1', function() {
var cmd = common.opensslCli + ' s_client -cipher ' + options.ciphers +
var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
' -connect 127.0.0.1:' + common.PORT;

exec(cmd, function(err, stdout, stderr) {
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var success_count = 0;
var error_count = 0;


exec(process.execPath + ' -p -e process.versions',
exec('"' + process.execPath + '" -p -e process.versions',
function(err, stdout, stderr) {
if (err) {
error_count++;
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var err;
var caught = false;
try
{
var cmd = util.format('%s -e "setTimeout(function(){}, %d);"',
var cmd = util.format('"%s" -e "setTimeout(function(){}, %d);"',
process.execPath, SLEEP);
var ret = execSync(cmd, {timeout: TIMER});
} catch (e) {
Expand All @@ -37,7 +37,7 @@ var msg = 'foobar';
var msgBuf = new Buffer(msg + '\n');

// console.log ends every line with just '\n', even on Windows.
cmd = util.format('%s -e "console.log(\'%s\');"', process.execPath, msg);
cmd = util.format('"%s" -e "console.log(\'%s\');"', process.execPath, msg);

var ret = execSync(cmd);

Expand Down
8 changes: 4 additions & 4 deletions test/sequential/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
var envCopy = JSON.parse(JSON.stringify(process.env));
envCopy.TEST_INIT = 1;

child.exec(process.execPath + ' test-init', {env: envCopy},
child.exec('"' + process.execPath + '" test-init', {env: envCopy},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!',
'`node test-init` failed!');
});
child.exec(process.execPath + ' test-init.js', {env: envCopy},
child.exec('"' + process.execPath + '" test-init.js', {env: envCopy},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!',
'`node test-init.js` failed!');
Expand All @@ -28,7 +28,7 @@
// test-init-index is in fixtures dir as requested by ry, so go there
process.chdir(common.fixturesDir);

child.exec(process.execPath + ' test-init-index', {env: envCopy},
child.exec('"' + process.execPath + '" test-init-index', {env: envCopy},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!',
'`node test-init-index failed!');
Expand All @@ -39,7 +39,7 @@
// expected in node
process.chdir(common.fixturesDir + '/test-init-native/');

child.exec(process.execPath + ' fs', {env: envCopy},
child.exec('"' + process.execPath + '" fs', {env: envCopy},
function(err, stdout, stderr) {
assert.equal(stdout, 'fs loaded successfully',
'`node fs` failed!');
Expand Down
6 changes: 2 additions & 4 deletions test/sequential/test-regress-GH-4015.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;

var cmd = process.execPath
+ ' '
+ common.fixturesDir
+ '/test-regress-GH-4015.js';
var cmd = '"' + process.execPath + '" ' +
'"' + common.fixturesDir + '/test-regress-GH-4015.js"';

exec(cmd, function(err, stdout, stderr) {
assert(/RangeError: Maximum call stack size exceeded/.test(stderr));
Expand Down

0 comments on commit 82f067e

Please sign in to comment.