Skip to content

Commit

Permalink
build: fine grain runfile dependencies for e2e tests
Browse files Browse the repository at this point in the history
Currently the e2e tests always include the `@angular/bazel` package in
the runfiles. This is causing a signifcant performance issue as the bazel
package brings in a lot of other packages resulting in a lot of files that need
to be symlinked by bazel.

Additionally duplication is avoided by having a macro for creating the
test suite target. This allows us to easily make such changes in the future
without having to go through all Bazel e2e targets.
  • Loading branch information
devversion authored and jelbourn committed Jul 11, 2019
1 parent a540edb commit e040db7
Show file tree
Hide file tree
Showing 32 changed files with 87 additions and 301 deletions.
13 changes: 3 additions & 10 deletions src/cdk-experimental/scrolling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "scrolling",
Expand Down Expand Up @@ -43,16 +44,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/cdk-experimental/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_web_test_suite", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_module", "ng_web_test_suite")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "testing",
Expand All @@ -18,16 +19,8 @@ ng_web_test_suite(
deps = ["//src/cdk-experimental/testing/tests:unit_test_sources"],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
"//src/cdk-experimental/testing/tests:e2e_test_sources",
"@npm//protractor",
Expand Down
12 changes: 2 additions & 10 deletions src/cdk/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
load(
"//tools:defaults.bzl",
"markdown_to_html",
"ng_e2e_test_library",
"ng_module",
"ng_test_library",
"ng_web_test_suite",
"protractor_web_test_suite",
)

ng_module(
Expand Down Expand Up @@ -76,16 +76,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
2 changes: 1 addition & 1 deletion src/e2e-app/start-devserver.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const protractor = require('protractor');
const utils = require('@angular/bazel/protractor-utils');
const utils = require('@angular/bazel/src/protractor/utils');
const spawn = require('child_process').spawn;

/**
Expand Down
15 changes: 15 additions & 0 deletions src/e2e-app/test_suite.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("//tools:defaults.bzl", "protractor_web_test_suite")

def e2e_test_suite(name, data = [], tags = ["e2e"], deps = []):
protractor_web_test_suite(
name = name,
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//:node_modules/@angular/bazel/src/protractor/utils/index.js",
] + data,
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = tags,
deps = deps,
)
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-button/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-button",
Expand Down Expand Up @@ -80,16 +81,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-card/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-card",
Expand Down Expand Up @@ -39,16 +40,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-checkbox/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "protractor_web_test_suite", "ts_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "ts_library")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-checkbox",
Expand Down Expand Up @@ -97,16 +98,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-chips/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-chips",
Expand Down Expand Up @@ -52,16 +53,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-menu/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-menu",
Expand Down Expand Up @@ -79,16 +80,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-radio/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-radio",
Expand Down Expand Up @@ -39,16 +40,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-slide-toggle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-slide-toggle",
Expand Down Expand Up @@ -76,16 +77,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
13 changes: 3 additions & 10 deletions src/material-experimental/mdc-tabs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")

ng_module(
name = "mdc-tabs",
Expand Down Expand Up @@ -49,16 +50,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
12 changes: 2 additions & 10 deletions src/material/button-toggle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
load(
"//tools:defaults.bzl",
"markdown_to_html",
"ng_e2e_test_library",
"ng_module",
"ng_test_library",
"ng_web_test_suite",
"protractor_web_test_suite",
)

ng_module(
Expand Down Expand Up @@ -71,16 +71,8 @@ ng_e2e_test_library(
],
)

protractor_web_test_suite(
e2e_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
Expand Down
Loading

0 comments on commit e040db7

Please sign in to comment.