Skip to content

Commit 29df634

Browse files
authored
feat(coverage): support web coverage reports in test_with_coverage (#2448)
Add support for web (Chrome) coverage collection and formatting in `test_with_coverage`. **VM runs keep the existing collection flow.** - Add a `-p` / `--platform` flag to `test_with_coverage`. Web (`chrome`) runs delegate to `dart test --coverage`; VM runs (the default, and `--function-coverage`) continue to use the existing VM-service collection flow. - Reject unsupported combinations during argument parsing rather than silently degrading: platforms other than `vm` / `chrome`, `--function-coverage` or `--branch-coverage` combined with a web platform, and platform flags passed through to the test script (`-- -p ...`). - Normalize `file:` URIs under a package's `lib/` root to `package:` URIs via `Resolver.toPackageUri` and apply `ScopedOutput.includesScript` in `HitMap.parseJsonSync` / `HitMap.parseJson` / `HitMap.parseFiles` so web runs report scoped library coverage matching VM semantics. Warn when no coverage data matches `--scope-output`. - Pre-flight `package:test` verification in `package_config.json`. - Fail fast and propagate the test process's exit code when the test process exits before the VM service is ready or before coverage collection finishes. Towards #2434
1 parent a66d517 commit 29df634

10 files changed

Lines changed: 850 additions & 90 deletions

File tree

‎pkgs/coverage/CHANGELOG.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
- Migrate Dart subprocess spawning to `package:cli_util` (`dartExecutable`) to support AOT-compiled executables (`dart compile exe` / `dart install`).
44
- Require Dart 3.9.
5+
- Support collecting and formatting web (V8 / Chrome) coverage reports in
6+
`test_with_coverage` via the new `-p` / `--platform` flag. Web runs delegate
7+
to `dart test --coverage`; VM runs continue to use the existing VM-service
8+
collection flow. Platforms other than `vm` and `chrome` are rejected, as are
9+
`--function-coverage` and `--branch-coverage` combined with a web platform,
10+
and platform flags passed through to the test script.
11+
Note that web coverage is measured on compiled JavaScript: code the compiler
12+
drops cannot be reported as uncovered, so line counts and percentages are not
13+
comparable to VM runs and `--fail-under` thresholds must be re-tuned per
14+
platform.
15+
- `test_with_coverage` now fails immediately when the test process exits before
16+
the VM service is ready (for example, when the test path does not exist)
17+
instead of waiting forever, and exits with the test process's exit code.
18+
- `HitMap.parseFiles` now throws a `FormatException` when a file is not a valid
19+
`{"coverage": [...]}` report, instead of silently ignoring it.
20+
- Support `scopeOutput` filtering in `HitMap.parseJsonSync`, `HitMap.parseJson`,
21+
and `HitMap.parseFiles`, normalizing `file:` URIs inside known package library
22+
roots to `package:` URIs via `Resolver.toPackageUri`.
523
- Fixed a race condition in isolate teardown: ignore the benign errors
624
produced when an isolate exits between its pause-on-exit callback
725
completing and the resume request reaching the VM service.

0 commit comments

Comments
 (0)