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:
		@@ -176,10 +176,19 @@ npm install -g typescript fried-twinkie
 | 
				
			|||||||
To run on all files, execute the following command:
 | 
					To run on all files, execute the following command:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```sh
 | 
					```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
 | 
					```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
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
@@ -125,21 +125,33 @@ sh_test(
 | 
				
			|||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sh_test(
 | 
					DIRECTORIES = [
 | 
				
			||||||
    name = "template_test",
 | 
					    "change",
 | 
				
			||||||
 | 
					    "change-list",
 | 
				
			||||||
 | 
					    "core",
 | 
				
			||||||
 | 
					    "diff",
 | 
				
			||||||
 | 
					    "plugins",
 | 
				
			||||||
 | 
					    "settings",
 | 
				
			||||||
 | 
					    "shared",
 | 
				
			||||||
 | 
					    "gr-app",
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[sh_test(
 | 
				
			||||||
 | 
					    name = "template_test_" + directory,
 | 
				
			||||||
    size = "large",
 | 
					    size = "large",
 | 
				
			||||||
    srcs = ["template_test.sh"],
 | 
					    srcs = ["template_test.sh"],
 | 
				
			||||||
 | 
					    args = [directory],
 | 
				
			||||||
    data = [
 | 
					    data = [
 | 
				
			||||||
        ":pg_code",
 | 
					        ":pg_code",
 | 
				
			||||||
        ":template_test_srcs",
 | 
					        ":template_test_srcs",
 | 
				
			||||||
        "//polygerrit-ui:polygerrit_components.bower_components.zip",
 | 
					        "//polygerrit-ui:polygerrit_components.bower_components.zip",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    # Should not run sandboxed.
 | 
					 | 
				
			||||||
    tags = [
 | 
					    tags = [
 | 
				
			||||||
 | 
					        # Should not run sandboxed.
 | 
				
			||||||
        "local",
 | 
					        "local",
 | 
				
			||||||
        "manual",
 | 
					        "template",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					) for directory in DIRECTORIES]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Embed bundle
 | 
					# Embed bundle
 | 
				
			||||||
polygerrit_bundle(
 | 
					polygerrit_bundle(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,4 +35,4 @@ export NODE_PATH=$(get_node_path)
 | 
				
			|||||||
unzip -o polygerrit-ui/polygerrit_components.bower_components.zip -d polygerrit-ui/app
 | 
					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
 | 
					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)
 | 
					# 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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,8 @@ def writeTempFile(file, root):
 | 
				
			|||||||
  if "gr-reporting" in file:
 | 
					  if "gr-reporting" in file:
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
  if not root in elements:
 | 
					  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"):
 | 
					  if file.endswith(".html") and not file.endswith("_test.html"):
 | 
				
			||||||
    # gr-navigation is treated like a behavior rather than a standard element
 | 
					    # gr-navigation is treated like a behavior rather than a standard element
 | 
				
			||||||
    # because of the way it added to the Gerrit object.
 | 
					    # because of the way it added to the Gerrit object.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,8 +45,21 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
 | 
				
			|||||||
  let mappings = JSON.parse(fs.readFileSync(
 | 
					  let mappings = JSON.parse(fs.readFileSync(
 | 
				
			||||||
      `./polygerrit-ui/temp/map.json`, 'utf-8'));
 | 
					      `./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.
 | 
					  // 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) {
 | 
					  if (file) {
 | 
				
			||||||
    const mappingSpecificFile = {};
 | 
					    const mappingSpecificFile = {};
 | 
				
			||||||
    for (key of Object.keys(mappings)) {
 | 
					    for (key of Object.keys(mappings)) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user