diff --git a/lib/runner/cli/clirunner.js b/lib/runner/cli/clirunner.js index 77ed47992e..5e18b0079c 100644 --- a/lib/runner/cli/clirunner.js +++ b/lib/runner/cli/clirunner.js @@ -85,7 +85,7 @@ CliRunner.prototype = { // reading the settings file try { this.settings = require(this.argv.config); - this.replaceEnvVariables(); + this.replaceEnvVariables(this.settings); this.manageSelenium = !this.isParallelMode() && this.settings.selenium && this.settings.selenium.start_process || false; @@ -109,16 +109,15 @@ CliRunner.prototype = { * @param {Object} [target] */ replaceEnvVariables : function(target) { - target = target || this.settings; for (var key in target) { switch(typeof target[key]) { - case 'object': - this.replaceEnvVariables(target[key]); + case 'object': + this.replaceEnvVariables(target[key]); break; - case 'string': - target[key] = target[key].replace(/\$\{(\w+)\}/g, function(match, varName) { - return process.env[varName] || '${' + varName + '}'; - }); + case 'string': + target[key] = target[key].replace(/\$\{(\w+)\}/g, function(match, varName) { + return process.env[varName] || '${' + varName + '}'; + }); break; } } diff --git a/test/src/runner/cli/testCliRunner.js b/test/src/runner/cli/testCliRunner.js index 69ffdd1e88..94fc454dd4 100644 --- a/test/src/runner/cli/testCliRunner.js +++ b/test/src/runner/cli/testCliRunner.js @@ -485,6 +485,27 @@ module.exports = { }, 'No testing environment specified.'); }, + testParseTestSettingsNull : function() { + mockery.registerMock('fs', { + statSync : function(module) { + if (module == './null.json') { + return {isFile : function() {return true;}}; + } + throw new Error('Does not exist'); + } + }); + + var CliRunner = common.require('runner/cli/clirunner.js'); + + var runner = new CliRunner({ + config : './null.json', + env : 'default' + }); + runner.init(); + assert.ok(typeof runner.settings.test_settings == 'object'); + assert.strictEqual(runner.settings.test_settings['default'].irrelevantProperty, null); + }, + testParseTestSettingsIncorrect : function() { mockery.registerMock('fs', { statSync : function(module) { @@ -708,6 +729,15 @@ module.exports = { src_folders : 'tests' }); + mockery.registerMock('./null.json', { + src_folders : 'tests', + test_settings : { + 'default' : { + irrelevantProperty: null + } + } + }); + mockery.registerMock('./incorrect.json', { src_folders : 'tests', test_settings : { @@ -849,6 +879,9 @@ module.exports = { if (b == './empty.json') { return './empty.json'; } + if (b == './null.json') { + return './null.json'; + } if (b == './incorrect.json') { return './incorrect.json'; }