Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit a199df8

Browse files
committed
test(e2e): run on Dartium, dart2js and sauce browsers
Command line runs will test Dartium by default if no BROWSERS are specified. If BROWSERS are specified, they all have to be local browsers or all sauce browsers. If you're only specifying sauce browsers (e.g. SL_Chrome, SL_Firefox, etc.), you may optionally also specify DartiumWithWebPlatform and this will run two instances of Protractor. (This is a limitation of Protractor's config.) On Travis, the job for a specific SDK version tests both DartiumWithWebPlatform as well as SL_Chrome. SL_Firefox is currently disabled because it's failing. Note that prior to this commit, the BROWSERS variable was always ignored.
1 parent 2d27a70 commit a199df8

File tree

5 files changed

+87
-69
lines changed

5 files changed

+87
-69
lines changed

.travis.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,14 @@ env:
2626
BROWSERS=SL_Chrome,SL_Firefox
2727
- JOB=e2e-g3stable
2828
CHANNEL=stable
29-
TESTS=vm
30-
BROWSERS=DartiumWithWebPlatform
29+
BROWSERS=DartiumWithWebPlatform,SL_Chrome
3130
USE_G3=YES
3231
- JOB=e2e-stable
3332
CHANNEL=stable
34-
TESTS=vm
35-
BROWSERS=DartiumWithWebPlatform
36-
- JOB=e2e-dev
37-
CHANNEL=dev
38-
TESTS=vm
39-
BROWSERS=DartiumWithWebPlatform
40-
- JOB=e2e-stable
41-
CHANNEL=stable
42-
TESTS=dart2js
43-
BROWSERS=SL_Chrome,SL_Firefox
33+
BROWSERS=DartiumWithWebPlatform,SL_Chrome
4434
- JOB=e2e-dev
4535
CHANNEL=dev
46-
TESTS=dart2js
47-
BROWSERS=SL_Chrome,SL_Firefox
36+
BROWSERS=DartiumWithWebPlatform,SL_Chrome
4837
global:
4938
- FIREFOX_VERSION="30.0"
5039
- CHROME_VERSION="35.0"

scripts/run-e2e-test.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,30 @@ fi
154154
run_protractor() {(
155155
local TEST_TYPE=$1
156156
local SPEC_FILE_VAR=TEST_${TEST_TYPE}_CONF
157-
./node_modules/.bin/protractor_dart ${!SPEC_FILE_VAR}
157+
# Default browsers if none specified.
158+
if [[ -z "$BROWSERS" ]]; then
159+
export BROWSERS=DartiumWithWebPlatform
160+
fi
161+
162+
# NOTE: Protractor can't test both sauce and local browsers in the same config.
163+
#
164+
# Local browsers only?
165+
if [[ ! "$BROWSERS" =~ SL_ ]]; then
166+
./node_modules/.bin/protractor_dart ${!SPEC_FILE_VAR}
167+
else
168+
# Assume that we have only sauce browsers. However, since
169+
# DartiumWithWebPlatform isn't on Sauce yet, we'll also support this common
170+
# use case by running twice - once for DartiumWithWebPlatform and again for
171+
# the sauce browsers.
172+
if [[ "$BROWSERS" =~ DartiumWithWebPlatform ]]; then
173+
BROWSERS=DartiumWithWebPlatform ./node_modules/.bin/protractor_dart ${!SPEC_FILE_VAR}
174+
fi
175+
BROWSERS="${BROWSERS#DartiumWithWebPlatform}"
176+
if [[ -n "$BROWSERS" ]]; then
177+
BROWSERS="${BROWSERS#,}"
178+
./node_modules/.bin/protractor_dart ${!SPEC_FILE_VAR}
179+
fi
180+
fi
158181
)}
159182
export -f run_protractor
160183

test_e2e/configQuery.js

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,62 @@ function getDartiumBinary() {
4444
}
4545

4646

47-
function getChromeOptions() {
48-
if (!runningOnTravis) {
49-
return {'binary': getDartiumBinary()};
47+
function updateConfigForBrowsers(config, browsers, shards) {
48+
shards = (shards == null) ? 1 : shards;
49+
if (!browsers) {
50+
throw new Error("updateConfigForBrowsers requires a list of browsers.");
51+
}
52+
if (browsers.length == 1 && browsers[0] == "DartiumWithWebPlatform") {
53+
config.multiCapabilities = [{
54+
browserName: 'chrome',
55+
chromeOptions: {
56+
binary: getDartiumBinary()
57+
},
58+
count: shards
59+
}];
60+
return;
61+
}
62+
63+
// We can either test with local browsers or those on SauceLabs but not both.
64+
var localBrowser = false, sauceBrowser = false;
65+
config.multiCapabilities = [];
66+
browsers.forEach(function(browser) {
67+
if (browser.indexOf("SL_") == 0) {
68+
sauceBrowser = true;
69+
browser = browser.substr(3).toLowerCase();
70+
} else {
71+
localBrowser = true;
72+
browser = browser.toLowerCase();
5073
}
51-
// In Travis, the list of browsers to test is specified as a CSV in the
52-
// BROWSERS environment variable.
53-
// TODO(chirayu): Parse the BROWSERS csv so we also test on Firefox.
54-
if (env.TESTS == "vm") {
55-
return {'binary': env.DARTIUM_BIN};
74+
if (localBrowser && sauceBrowser) {
75+
throw new Error(
76+
"You can either tests against local browsers or sauce " +
77+
"browsers but not both.");
5678
}
57-
if (env.TESTS == "dart2js") {
58-
return {
59-
'binary': env.CHROME_BIN,
60-
// Ref: https://github.com/travis-ci/travis-ci/issues/938
61-
// https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start
62-
'args': ['no-sandbox=true']
79+
var capability = { browserName: browser };
80+
if (browser == "chrome") {
81+
capability.chromeOptions = {
82+
// Ref: https://github.com/travis-ci/travis-ci/issues/938
83+
// https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start
84+
args: ['no-sandbox=true']
6385
};
86+
if (localBrowser && env.CHROME_BIN) {
87+
capability.chromeOptions.binary = env.CHROME_BIN;
88+
}
6489
}
65-
throw new Error("Unknown Travis configuration specified by TESTS variable");
66-
}
90+
config.multiCapabilities.push(capability);
91+
});
6792

93+
if (sauceBrowser) {
94+
config.seleniumAddress = null;
95+
config.sauceUser = env.SAUCE_USERNAME;
96+
config.sauceKey = env.SAUCE_ACCESS_KEY;
97+
config.multiCapabilities.forEach(function(capability) {
98+
capability['tunnel-identifier'] = env.TRAVIS_JOB_NUMBER;
99+
capability['build'] = env.TRAVIS_BUILD_NUMBER;
100+
});
101+
}
102+
}
68103

69104
exports.getBaseUrl = getBaseUrl;
70-
exports.getChromeOptions = getChromeOptions;
105+
exports.updateConfigForBrowsers = updateConfigForBrowsers;

test_e2e/examplesConf.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ var config = {
2323

2424
splitTestsBetweenCapabilities: true,
2525

26-
multiCapabilities: [{
27-
browserName: 'chrome',
28-
chromeOptions: configQuery.getChromeOptions(),
29-
count: 4
30-
}],
31-
3226
baseUrl: configQuery.getBaseUrl({
3327
envVar: "TEST_EXAMPLE_BASEURL"
3428
}),
@@ -41,17 +35,9 @@ var config = {
4135
},
4236
};
4337

44-
// Saucelabs case.
45-
if (process.env.SAUCE_USERNAME != null) {
46-
config.sauceUser = process.env.SAUCE_USERNAME;
47-
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
48-
config.seleniumAddress = null;
49-
50-
config.multiCapabilities.forEach(function(capability) {
51-
capability['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
52-
capability['build'] = process.env.TRAVIS_BUILD_NUMBER;
53-
capability['name'] = 'AngularDart E2E Suite';
54-
});
55-
}
38+
configQuery.updateConfigForBrowsers(config, process.env.BROWSERS.split(","), 4);
39+
config.multiCapabilities.forEach(function(capability) {
40+
capability['name'] = 'AngularDart E2E Suite';
41+
});
5642

5743
exports.config = config;

test_transformers/transformersE2eConf.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,10 @@ var config = {
1818

1919
specs: ['relative_uris_spec.dart'],
2020

21-
multiCapabilities: [{
22-
browserName: 'chrome',
23-
chromeOptions: configQuery.getChromeOptions(),
24-
count: 1
25-
}],
26-
2721
baseUrl: configQuery.getBaseUrl({
2822
envVar: "TEST_TRANSFORMERS_BASEURL"
2923
}),
3024

31-
3225
jasmineNodeOpts: {
3326
isVerbose: true, // display spec names.
3427
showColors: true, // print colors to the terminal.
@@ -37,17 +30,9 @@ var config = {
3730
},
3831
};
3932

40-
// Saucelabs case.
41-
if (process.env.SAUCE_USERNAME != null) {
42-
config.sauceUser = process.env.SAUCE_USERNAME;
43-
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
44-
config.seleniumAddress = null;
45-
46-
config.multiCapabilities.forEach(function(capability) {
47-
capability['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
48-
capability['build'] = process.env.TRAVIS_BUILD_NUMBER;
49-
capability['name'] = 'AngularDart Transformers E2E Suite';
50-
});
51-
}
33+
configQuery.updateConfigForBrowsers(config, process.env.BROWSERS.split(","), 1);
34+
config.multiCapabilities.forEach(function(capability) {
35+
capability['name'] = 'AngularDart Transformers E2E Suite';
36+
});
5237

5338
exports.config = config;

0 commit comments

Comments
 (0)