From de153e769292f6b9a99b2d5152bd2929ab1c48af Mon Sep 17 00:00:00 2001 From: Craig Date: Tue, 27 Dec 2016 12:21:17 -0800 Subject: [PATCH] fix(launcher): running getMultiCapabilities should reject on errors (#3876) closes #3875 --- lib/launcher.ts | 17 ++++++++++++----- scripts/{exitCodes.js => errorTest.js} | 7 +++++++ scripts/test.js | 2 +- spec/errorTest/getMultiCapabilitiesConf.js | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) rename scripts/{exitCodes.js => errorTest.js} (87%) create mode 100644 spec/errorTest/getMultiCapabilitiesConf.js diff --git a/lib/launcher.ts b/lib/launcher.ts index 9ecc0a310..6a92e20ea 100644 --- a/lib/launcher.ts +++ b/lib/launcher.ts @@ -112,7 +112,7 @@ let initFn = function(configFile: string, additionalConfig: Config) { .then(() => { return q - .Promise((resolve: Function) => { + .Promise((resolve: Function, reject: Function) => { // 1) If getMultiCapabilities is set, resolve that as // `multiCapabilities`. if (config.getMultiCapabilities && @@ -123,10 +123,17 @@ let initFn = function(configFile: string, additionalConfig: Config) { 'and multiCapabilities'); } // If getMultiCapabilities is defined and a function, use this. - q.when(config.getMultiCapabilities(), (multiCapabilities) => { - config.multiCapabilities = multiCapabilities; - config.capabilities = null; - }).then(() => resolve()); + q(config.getMultiCapabilities()) + .then((multiCapabilities) => { + config.multiCapabilities = multiCapabilities; + config.capabilities = null; + }) + .then(() => { + resolve(); + }) + .catch(err => { + reject(err); + }); } else { resolve(); } diff --git a/scripts/exitCodes.js b/scripts/errorTest.js similarity index 87% rename from scripts/exitCodes.js rename to scripts/errorTest.js index 2446b7dc1..4a2effe80 100644 --- a/scripts/exitCodes.js +++ b/scripts/errorTest.js @@ -44,3 +44,10 @@ messages = [ 'Cannot run in debug mode with multiCapabilities, count > 1, or sharding', 'Process exited with error code ' + exitCodes.ConfigError.CODE]; checkLogs(output, messages); + +runProtractor = spawn('node', + ['bin/protractor', 'spec/errorTest/getMultiCapabilitiesConf.js']); +output = runProtractor.stderr.toString(); +messages = [ + 'Error: get multi capabilities failed']; +checkLogs(output, messages); diff --git a/scripts/test.js b/scripts/test.js index fb259729c..4213b1e7d 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -36,7 +36,7 @@ var passingTests = [ 'node built/cli.js spec/angular2Conf.js', 'node built/cli.js spec/hybridConf.js', 'node scripts/driverProviderAttachSession.js', - 'node scripts/exitCodes.js', + 'node scripts/errorTest.js', 'node scripts/interactive_tests/interactive_test.js', 'node scripts/interactive_tests/with_base_url.js', // Unit tests diff --git a/spec/errorTest/getMultiCapabilitiesConf.js b/spec/errorTest/getMultiCapabilitiesConf.js new file mode 100644 index 000000000..cdcb00e1f --- /dev/null +++ b/spec/errorTest/getMultiCapabilitiesConf.js @@ -0,0 +1,18 @@ +var env = require('../environment.js'); + +exports.config = { + seleniumAddress: env.seleniumAddress, + + // Spec patterns are relative to this directory. + specs: [ + '../../basic/mock*' + ], + + getMultiCapabilities: function() { + return new Promise((resolve) => { + throw new Error('get multi capabilities failed'); + }); + }, + + baseUrl: env.baseUrl + '/ng1/' +};