Pete Bacon Darwin 9066ca9e92 test(compiler-cli): add support for source-map checks in compliance tests (#39939)
This commit allows compliance test-cases to be written that specify
source-map mappings between the source and generated code.

To check a mapping, add a `// SOURCE:` comment to the end of a line:

```
<generated code> // SOURCE: "<source-url>" <source code>
```

The generated code will still be checked, stripped of the `// SOURCE` comment,
as normal by the `expectEmit()` helper.

In addition, the source-map segments are checked to ensure that there is a
mapping from `<generated code>` to `<source code>` found in the file at
`<source-url>`.

Note:

* The source-url should be absolute, with the directory containing the
  TEST_CASES.json file assumed to be `/`.
* Whitespace is important and will be included when comparing the segments.
* There is a single space character between each part of the line.
* Newlines within a mapping must be escaped since the mapping and comment
  must all appear on a single line of this file.

PR Close #39939
2020-12-07 16:21:05 -08:00

32 lines
855 B
Python

load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
ts_library(
name = "test_lib",
testonly = True,
srcs = ["linked_compile_spec.ts"],
deps = [
"//packages/compiler-cli/linker/babel",
"//packages/compiler-cli/src/ngtsc/file_system",
"//packages/compiler-cli/src/ngtsc/logging",
"//packages/compiler-cli/src/ngtsc/sourcemaps",
"//packages/compiler-cli/test/compliance/test_helpers",
"@npm//@types/babel__core",
],
)
jasmine_node_test(
name = "linked",
bootstrap = ["//tools/testing:node_no_angular_es5"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
"//packages/compiler-cli/test/compliance/test_cases",
],
shard_count = 2,
tags = [
"ivy-only",
],
deps = [
":test_lib",
],
)