Skip to content

Commit 15e671e

Browse files
gregmagolanAndrewKushnir
authored andcommitted
build(bazel): upgrade benchmarks to protractor_web_test_suite for CI without local chrome (angular#26908)
PR Close angular#26908
1 parent 3567e81 commit 15e671e

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

modules/benchmarks/src/largetable/render3/BUILD.bazel

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
4-
load("//packages/bazel:index.bzl", "protractor_web_test")
4+
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
55
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
66

77
ng_module(
@@ -50,7 +50,7 @@ ts_devserver(
5050
tags = ["ivy-only"],
5151
)
5252

53-
protractor_web_test(
53+
protractor_web_test_suite(
5454
name = "perf",
5555
configuration = "//:protractor-perf.conf.js",
5656
data = [
@@ -64,8 +64,6 @@ protractor_web_test(
6464
on_prepare = ":protractor.on_prepare.js",
6565
server = ":devserver",
6666
tags = [
67-
"fixme-ivy-aot",
68-
"fixme-ivy-jit",
6967
"ivy-only",
7068
],
7169
deps = [

modules/benchmarks/src/tree/render3/BUILD.bazel

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
4-
load("//packages/bazel:index.bzl", "protractor_web_test")
4+
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
55
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
66

77
ng_module(
@@ -48,7 +48,7 @@ ts_devserver(
4848
tags = ["ivy-only"],
4949
)
5050

51-
protractor_web_test(
51+
protractor_web_test_suite(
5252
name = "perf",
5353
configuration = "//:protractor-perf.conf.js",
5454
data = [
@@ -58,8 +58,6 @@ protractor_web_test(
5858
on_prepare = ":protractor.on_prepare.js",
5959
server = ":devserver",
6060
tags = [
61-
"fixme-ivy-aot",
62-
"fixme-ivy-jit",
6361
"ivy-only",
6462
],
6563
deps = [

packages/bazel/src/protractor/protractor.conf.js

+33-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
9-
const path = require('path');
10-
118
const DEBUG = false;
129

1310
const configPath = 'TMPL_config';
@@ -32,15 +29,44 @@ function setConf(conf, name, value, msg) {
3229
conf[name] = value;
3330
}
3431

32+
function mergeCapabilities(conf, capabilities) {
33+
if (conf.capabilities) {
34+
if (conf.capabilities.browserName === capabilities.browserName) {
35+
// there are capabilities to merge
36+
if (capabilities.browserName === 'chrome') {
37+
conf.capabilities.chromeOptions = conf.capabilities.chromeOptions || {};
38+
conf.capabilities.chromeOptions.binary = capabilities.chromeOptions.binary;
39+
conf.capabilities.chromeOptions.args = conf.capabilities.chromeOptions.args || [];
40+
conf.capabilities.chromeOptions.args.push(...capabilities.chromeOptions.args);
41+
console.warn(
42+
`Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}'
43+
which will be merged with capabilities provided by Bazel resulting in:`,
44+
JSON.stringify(conf.capabilities, null, 2));
45+
} else {
46+
// TODO(gmagolan): implement firefox support for protractor
47+
throw new Error(
48+
`Unexpected browserName ${capabilities.browserName} for capabilities merging`);
49+
}
50+
} else {
51+
console.warn(
52+
`Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}' which will be overwritten by Bazel`);
53+
conf.capabilities = capabilities;
54+
}
55+
} else {
56+
conf.capabilities = capabilities;
57+
}
58+
}
59+
3560
let conf = {};
3661

3762
// Import the user's base protractor configuration if specified
3863
if (configPath) {
3964
const baseConf = require(configPath);
4065
if (!baseConf.config) {
41-
throw new Error('Invalid base protractor configration. Expected config to be exported.');
66+
throw new Error('Invalid base protractor configuration. Expected config to be exported.');
4267
}
4368
conf = baseConf.config;
69+
if (DEBUG) console.info(`Base protractor configuration: ${JSON.stringify(conf, null, 2)}`);
4470
}
4571

4672
// Import the user's on prepare function if specified
@@ -109,8 +135,8 @@ if (process.env['WEB_TEST_METADATA']) {
109135
}
110136
setConf(conf, 'directConnect', true, 'is set to true for chrome');
111137
setConf(conf, 'chromeDriver', chromeDriver, 'is determined by the browsers attribute');
112-
setConf(
113-
conf, 'capabilities', {
138+
mergeCapabilities(
139+
conf, {
114140
browserName: 'chrome',
115141
chromeOptions: {
116142
binary: chromeBin,
@@ -131,7 +157,7 @@ if (process.env['WEB_TEST_METADATA']) {
131157
// }
132158
// setConf(conf, 'seleniumAddress', process.env.WEB_TEST_HTTP_SERVER.trim() + "/wd/hub", 'is
133159
// configured by Bazel for firefox browser')
134-
// setConf(conf, 'capabilities', {
160+
// mergeCapabilities(conf, {
135161
// browserName: "firefox",
136162
// 'moz:firefoxOptions': {
137163
// binary: firefoxBin,

0 commit comments

Comments
 (0)