From 82f067e60bb3eb87cc1119655ae0a5968e988326 Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Thu, 12 Mar 2015 10:16:26 +0900 Subject: [PATCH] test: fix ext commands to be double quoted 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: https://github.com/iojs/io.js/pull/1122 Reviewed-by: Bert Belder --- test/parallel/test-eval.js | 2 +- test/parallel/test-fs-readfile-error.js | 2 +- test/parallel/test-http-curl-chunk-problem.js | 3 ++- test/parallel/test-tls-ecdh-disable.js | 2 +- test/parallel/test-tls-ecdh.js | 2 +- test/parallel/test-tls-set-ciphers.js | 2 +- test/pummel/test-exec.js | 2 +- test/sequential/test-child-process-execsync.js | 4 ++-- test/sequential/test-init.js | 8 ++++---- test/sequential/test-regress-GH-4015.js | 6 ++---- 10 files changed, 16 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-eval.js b/test/parallel/test-eval.js index 769c3a9b1985e5..e504ceca12678c 100644 --- a/test/parallel/test-eval.js +++ b/test/parallel/test-eval.js @@ -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) { diff --git a/test/parallel/test-fs-readfile-error.js b/test/parallel/test-fs-readfile-error.js index b8cf3e01757092..bfe79ab80edb63 100644 --- a/test/parallel/test-fs-readfile-error.js +++ b/test/parallel/test-fs-readfile-error.js @@ -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); diff --git a/test/parallel/test-http-curl-chunk-problem.js b/test/parallel/test-http-curl-chunk-problem.js index 58e195d4b4168a..fcb186153dc933 100644 --- a/test/parallel/test-http-curl-chunk-problem.js +++ b/test/parallel/test-http-curl-chunk-problem.js @@ -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]; diff --git a/test/parallel/test-tls-ecdh-disable.js b/test/parallel/test-tls-ecdh-disable.js index e479a7e21b238f..1799ec454c0cec 100644 --- a/test/parallel/test-tls-ecdh-disable.js +++ b/test/parallel/test-tls-ecdh-disable.js @@ -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) { diff --git a/test/parallel/test-tls-ecdh.js b/test/parallel/test-tls-ecdh.js index 55023aad5ad0f6..042491672ff407 100644 --- a/test/parallel/test-tls-ecdh.js +++ b/test/parallel/test-tls-ecdh.js @@ -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) { diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js index 62ca077f29c8c2..ba4341633b0895 100644 --- a/test/parallel/test-tls-set-ciphers.js +++ b/test/parallel/test-tls-set-ciphers.js @@ -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) { diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 9665f6b81a0b22..bbedc3a5729515 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -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++; diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 91105e4620eaf3..5cd9ee433d6d35 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -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) { @@ -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); diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js index b2f25899c2c128..abc6378a637e93 100644 --- a/test/sequential/test-init.js +++ b/test/sequential/test-init.js @@ -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!'); @@ -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!'); @@ -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!'); diff --git a/test/sequential/test-regress-GH-4015.js b/test/sequential/test-regress-GH-4015.js index 9fce060ad223c5..38a77c82086b1c 100644 --- a/test/sequential/test-regress-GH-4015.js +++ b/test/sequential/test-regress-GH-4015.js @@ -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));