Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(launcher): running getMultiCapabilities should reject on errors (#…
Browse files Browse the repository at this point in the history
…3876)

closes #3875
  • Loading branch information
cnishina authored Dec 27, 2016
1 parent ca4f1ac commit de153e7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
17 changes: 12 additions & 5 deletions lib/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let initFn = function(configFile: string, additionalConfig: Config) {
.then(() => {

return q
.Promise<any>((resolve: Function) => {
.Promise<any>((resolve: Function, reject: Function) => {
// 1) If getMultiCapabilities is set, resolve that as
// `multiCapabilities`.
if (config.getMultiCapabilities &&
Expand All @@ -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();
}
Expand Down
7 changes: 7 additions & 0 deletions scripts/exitCodes.js → scripts/errorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions spec/errorTest/getMultiCapabilitiesConf.js
Original file line number Diff line number Diff line change
@@ -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/'
};

0 comments on commit de153e7

Please sign in to comment.