Create separate bazel test target for each directory's template test

Previously, running the entire template test suite took about twelve
minutes. In order to speed this up, test top level directories as
individual test targets that can be run in parallel.

It now takes about 4 minutes to run everything (on a Macbook Pro)

Documentation updated as well, as commands have changed.

Change-Id: Ie815a7fafc64b442f36b92d0d295f8cfbe12cc0d
This commit is contained in:
Becky Siegel 2017-08-15 11:51:09 -07:00
parent cf6bb11809
commit b43e9957b3
5 changed files with 46 additions and 11 deletions

View File

@ -176,10 +176,19 @@ npm install -g typescript fried-twinkie
To run on all files, execute the following command:
```sh
bazel test //polygerrit-ui/app:template_test
bazel test //polygerrit-ui/app:all --test_tag_filters=template --test_output errors
```
To run on a specific file (ex: gr-list-view), execute the following command:
To run on a specific top level directory (ex: change-list)
```sh
bazel test //polygerrit-ui/app:template_test --test_arg=gr-list-view
bazel test //polygerrit-ui/app:template_test_change-list --test_output errors
```
To run on a specific file (ex: gr-change-list-view), execute the following command:
```sh
bazel test //polygerrit-ui/app:template_test_<TOP_LEVEL_DIRECTORY> --test_arg=<VIEW_NAME> --test_output errors
```
```sh
bazel test //polygerrit-ui/app:template_test_change-list --test_arg=gr-change-list-view --test_output errors
```

View File

@ -125,21 +125,33 @@ sh_test(
],
)
sh_test(
name = "template_test",
DIRECTORIES = [
"change",
"change-list",
"core",
"diff",
"plugins",
"settings",
"shared",
"gr-app",
]
[sh_test(
name = "template_test_" + directory,
size = "large",
srcs = ["template_test.sh"],
args = [directory],
data = [
":pg_code",
":template_test_srcs",
"//polygerrit-ui:polygerrit_components.bower_components.zip",
],
# Should not run sandboxed.
tags = [
# Should not run sandboxed.
"local",
"manual",
"template",
],
)
) for directory in DIRECTORIES]
# Embed bundle
polygerrit_bundle(

View File

@ -35,4 +35,4 @@ export NODE_PATH=$(get_node_path)
unzip -o polygerrit-ui/polygerrit_components.bower_components.zip -d polygerrit-ui/app
python $TEST_SRCDIR/gerrit/polygerrit-ui/app/template_test_srcs/convert_for_template_tests.py
# Pass a file name argument from the --test_args (example: --test_arg=gr-list-view)
${node_bin} $TEST_SRCDIR/gerrit/polygerrit-ui/app/template_test_srcs/template_test.js $1
${node_bin} $TEST_SRCDIR/gerrit/polygerrit-ui/app/template_test_srcs/template_test.js $1 $2

View File

@ -55,7 +55,8 @@ def writeTempFile(file, root):
if "gr-reporting" in file:
return
if not root in elements:
elements[root] = {}
# gr-app doesn't have an additional level
elements[root] = {"directory": 'gr-app' if len(root.split("/")) < 4 else root.split("/")[3]}
if file.endswith(".html") and not file.endswith("_test.html"):
# gr-navigation is treated like a behavior rather than a standard element
# because of the way it added to the Gerrit object.

View File

@ -45,8 +45,21 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
let mappings = JSON.parse(fs.readFileSync(
`./polygerrit-ui/temp/map.json`, 'utf-8'));
// The directory is passed as arg2 by the test target.
const directory = process.argv[2];
if (directory) {
const mappingSpecificDirectory = {};
for (key of Object.keys(mappings)) {
if (directory === mappings[key].directory) {
mappingSpecificDirectory[key] = mappings[key];
}
}
mappings = mappingSpecificDirectory;
}
// If a particular file was passed by the user, don't test everything.
const file = process.argv[2];
const file = process.argv[3];
if (file) {
const mappingSpecificFile = {};
for (key of Object.keys(mappings)) {