diff --git a/test/integration/helpers.js b/test/integration/helpers.js index ab26912..e6977ab 100644 --- a/test/integration/helpers.js +++ b/test/integration/helpers.js @@ -28,7 +28,9 @@ try { assert.string(CONFIG.url, 'test/config.json#url'); assert.string(CONFIG.account, 'test/config.json#account'); assert.string(CONFIG.key_id, 'test/config.json#key_id'); - assert.optionalBool(CONFIG.insecure, 'test/config.json#insecure'); + if (CONFIG.insecure === undefined) + CONFIG.insecure = false; + assert.bool(CONFIG.insecure, 'test/config.json#insecure'); } catch (e) { error('* * *'); error('node-triton integration tests require a ./test/config.json'); @@ -46,7 +48,7 @@ try { throw e; } -var TRITON = 'node ' + path.resolve(__dirname, '../../bin/triton'); +var TRITON = [process.execPath, path.resolve(__dirname, '../../bin/triton')]; var UA = 'node-triton-test'; var LOG = require('../lib/log'); @@ -59,13 +61,18 @@ var LOG = require('../lib/log'); * Call the `triton` CLI with the given args. */ function triton(args, cb) { + var command = [].concat(TRITON).concat(args); + if (typeof (args) === 'string') + command = command.join(' '); + testcommon.execPlus({ - command: TRITON + ' ' + args, + command: command, execOpts: { maxBuffer: Infinity, env: { PATH: process.env.PATH, HOME: process.env.HOME, + SSH_AUTH_SOCK: process.env.SSH_AUTH_SOCK, SDC_URL: CONFIG.url, SDC_ACCOUNT: CONFIG.account, SDC_KEY_ID: CONFIG.key_id, diff --git a/test/lib/testcommon.js b/test/lib/testcommon.js index 03d1cab..e393ebe 100644 --- a/test/lib/testcommon.js +++ b/test/lib/testcommon.js @@ -9,7 +9,7 @@ */ var assert = require('assert-plus'); -var exec = require('child_process').exec; +var execFile = require('child_process').execFile; var VError = require('verror').VError; @@ -21,7 +21,7 @@ var VError = require('verror').VError; * logging and error handling boilerplate. * * @param args {Object} - * - command {String} Required. + * - command {String|Array} Required. * - log {Bunyan Logger} Required. Use to log details at trace level. * - execOpts {Array} Optional. child_process.exec options. * - errMsg {String} Optional. Error string to use in error message on @@ -38,10 +38,11 @@ function execPlus(args, cb) { assert.func(cb); var command = args.command; var execOpts = args.execOpts; + if (typeof (command) === 'string') + command = ['/bin/sh', '-c', command]; - // args.log.trace({exec: true, command: command, execOpts: execOpts}, - // 'exec start'); - exec(command, execOpts, function (err, stdout, stderr) { + execFile(command[0], command.slice(1), execOpts, + function (err, stdout, stderr) { args.log.trace({exec: true, command: command, execOpts: execOpts, err: err, stdout: stdout, stderr: stderr}, 'exec done'); if (err) {