test(compiler-cli): update new compliance test partial rules (#39661)

There is now a dedicated rule for debugging generation of partial
golden files. The README has been updated accordingly.

PR Close #39661
This commit is contained in:
Pete Bacon Darwin 2020-11-17 15:59:02 +00:00 committed by Jessica Janiuk
parent 6653028863
commit 63dcfb2913
2 changed files with 36 additions and 18 deletions

View File

@ -114,7 +114,6 @@ yarn test-ivy-aot //packages/compiler-cli/test/compliance/test_cases/...
(The last command runs the partial compilation tests.) (The last command runs the partial compilation tests.)
## Updating a golden partial file ## Updating a golden partial file
There is one golden partial file per `TEST_CASES.json` file. So even if this file defines multiple There is one golden partial file per `TEST_CASES.json` file. So even if this file defines multiple
@ -137,11 +136,22 @@ that contains the `GOLDEN_PARTIAL.js` to update.
## Debugging test-cases ## Debugging test-cases
Compliance tests are basically `jasmine_node_test` rules. As such, they can be debugged The full and linked compliance tests are basically `jasmine_node_test` rules. As such, they can be
just like any other `jasmine_node_test`. The standard approach is to add `--config=debug` debugged just like any other `jasmine_node_test`. The standard approach is to add `--config=debug`
to the Bazel test command. to the Bazel test command.
It is useful when debugging to focus on a single test-case. For example:
```sg
yarn test-ivy-aot //packages/compiler-cli/test/compliance/full --config=debug
yarn test-ivy-aot //packages/compiler-cli/test/compliance/linked --config=debug
```
To debug generating the partial golden output use the following form of Bazel command:
```sh
yarn bazel run //packages/compiler-cli/test/compliance/test_cases:generate_partial_for_<path/to/test_case>.debug
```
### Focusing test-cases ### Focusing test-cases
@ -154,4 +164,3 @@ This is equivalent to using jasmine `fit()`.
You can exclude a test case by setting `"excludeTest": true` in the `TEST_CASES.json` file. You can exclude a test case by setting `"excludeTest": true` in the `TEST_CASES.json` file.
This is equivalent to using jasmine `xit()`. This is equivalent to using jasmine `xit()`.

View File

@ -6,26 +6,39 @@ def partial_compliance_golden(filePath):
# Remove the "TEST_CASES.json" substring from the end of the provided path. # Remove the "TEST_CASES.json" substring from the end of the provided path.
path = filePath[:-len("/TEST_CASES.json")] path = filePath[:-len("/TEST_CASES.json")]
generate_partial_name = "generate_partial_for_%s" % path
nodejs_binary(
name = "_generate_%s" % path,
testonly = True,
data = [ data = [
"//packages/compiler-cli/test/compliance/partial:generate_golden_partial_lib", "//packages/compiler-cli/test/compliance/partial:generate_golden_partial_lib",
"//packages/compiler-cli/test/compliance/test_cases", "//packages/compiler-cli/test/compliance/test_cases",
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package", "//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
], ]
nodejs_binary(
name = generate_partial_name,
testonly = True,
data = data,
visibility = [":__pkg__"], visibility = [":__pkg__"],
entry_point = "//packages/compiler-cli/test/compliance/partial:cli.ts", entry_point = "//packages/compiler-cli/test/compliance/partial:cli.ts",
templated_args = [ templated_args = [
# "--node_options=--inspect-brk", filePath,
],
)
nodejs_binary(
name = generate_partial_name + ".debug",
testonly = True,
data = data,
visibility = [":__pkg__"],
entry_point = "//packages/compiler-cli/test/compliance/partial:cli.ts",
templated_args = [
"--node_options=--inspect-brk",
filePath, filePath,
], ],
) )
npm_package_bin( npm_package_bin(
name = "_generated_%s" % path, name = "_generated_%s" % path,
tool = "_generate_%s" % path, tool = generate_partial_name,
testonly = True, testonly = True,
stdout = "%s/this_file_should_not_be_committed" % path, stdout = "%s/this_file_should_not_be_committed" % path,
link_workspace_root = True, link_workspace_root = True,
@ -34,11 +47,7 @@ def partial_compliance_golden(filePath):
"no-windows", "no-windows",
], ],
visibility = [":__pkg__"], visibility = [":__pkg__"],
data = [ data = data,
"//packages/compiler-cli/test/compliance/partial:generate_golden_partial_lib",
"//packages/compiler-cli/test/compliance/test_cases",
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
],
) )
generated_file_test( generated_file_test(