Skip to content

feat(coverage): support web coverage reports in test_with_coverage - #2448

Draft
kevmoo wants to merge 24 commits into
mainfrom
web_coverage
Draft

feat(coverage): support web coverage reports in test_with_coverage#2448
kevmoo wants to merge 24 commits into
mainfrom
web_coverage

Conversation

@kevmoo

@kevmoo kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member

Add support for web (V8 / Chrome) coverage collection, parsing, and formatting in package:coverage.

  • Delegate test execution in test_with_coverage.dart to dart test --coverage with -p / --platform support.
  • Auto-detect raw Chrome V8 coverage JSON lists in HitMap.parseFiles.
  • Add pre-flight package:test verification and file: URI normalization via package:package_config.
  • Add explicit line-hit assertions in integration and unit tests.
  • Update GitHub Actions workflow to run VM and Chrome tests in CI.

Fixes #2434
Fixes #471

Add support for web (V8 / Chrome) coverage collection, parsing, and formatting in package:coverage.

- Delegate test execution in test_with_coverage.dart to dart test --coverage with -p / --platform support.
- Auto-detect raw Chrome V8 coverage JSON lists in HitMap.parseFiles.
- Add pre-flight package:test verification and file: URI normalization via package:package_config.
- Add explicit line-hit assertions in integration and unit tests.
- Update GitHub Actions workflow to run VM and Chrome tests in CI.

Fixes #2434
@kevmoo
kevmoo requested review from a team and liamappelbe as code owners July 1, 2026 02:03
@github-actions github-actions Bot added type-infra A repository infrastructure change or enhancement package:coverage labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Package publishing

If you have publishing permissions, you can use the links below to publish the changes after merging this PR.

Package Version Status Publish tag (post-merge)
package:api_summary 0.1.0-wip WIP (no publish necessary)
package:bazel_worker 1.1.5 already published at pub.dev
package:benchmark_harness 2.4.0 already published at pub.dev
package:boolean_selector 2.1.2 already published at pub.dev
package:browser_launcher 1.2.0-wip WIP (no publish necessary)
package:cli_config 0.2.1-wip WIP (no publish necessary)
package:cli_util 0.5.1 already published at pub.dev
package:clock 1.1.3-wip WIP (no publish necessary)
package:code_builder 4.12.0-wip WIP (no publish necessary)
package:coverage 1.16.0-wip WIP (no publish necessary)
package:csslib 1.0.2 already published at pub.dev
package:extension_discovery 2.1.0 already published at pub.dev
package:file 7.0.2-wip WIP (no publish necessary)
package:file_testing 3.1.0-wip WIP (no publish necessary)
package:glob 2.1.3 already published at pub.dev
package:graphs 2.4.0-wip WIP (no publish necessary)
package:html 0.15.7-wip WIP (no publish necessary)
package:io 1.1.0-wip WIP (no publish necessary)
package:json_rpc_2 4.1.0 already published at pub.dev
package:markdown 7.4.0 ready to publish markdown-v7.4.0
package:mime 2.1.0-wip WIP (no publish necessary)
package:oauth2 2.0.5 already published at pub.dev
package:package_config 3.0.0 already published at pub.dev
package:pool 1.5.3-wip WIP (no publish necessary)
package:process 5.0.5 (error) pubspec version (5.0.5) and changelog (5.0.6-wip) don't agree
package:pub_semver 2.2.0 already published at pub.dev
package:pubspec_parse 1.6.0-wip WIP (no publish necessary)
package:source_map_stack_trace 2.1.3-wip WIP (no publish necessary)
package:source_maps 0.10.14-wip WIP (no publish necessary)
package:source_span 1.10.2 already published at pub.dev
package:sse 4.2.1-wip WIP (no publish necessary)
package:stack_trace 1.12.2-wip (error) pubspec version (1.12.2-wip) and changelog (1.12.2-dev) don't agree
package:stream_channel 2.1.4 already published at pub.dev
package:stream_transform 2.1.2-wip WIP (no publish necessary)
package:string_scanner 1.4.2-wip WIP (no publish necessary)
package:term_glyph 1.2.3-wip WIP (no publish necessary)
package:test_reflective_loader 0.6.0 ready to publish test_reflective_loader-v0.6.0
package:timing 1.0.2 already published at pub.dev
package:unified_analytics 8.0.16-wip WIP (no publish necessary)
package:watcher 1.2.2-wip WIP (no publish necessary)
package:yaml 3.1.4-wip WIP (no publish necessary)
package:yaml_edit 2.2.4 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for collecting and formatting Web (V8 / Chrome) coverage reports in test_with_coverage via a new -p / --platform flag, and adds support for parsing raw Chrome V8 coverage JSON lists in HitMap.parseFiles. The review feedback highlights several critical issues: the raw Chrome V8 precise coverage JSON list parsing path is currently non-functional because the source and source map providers are hardcoded to return null; if no coverage files are found, the output JSON is not written, which will cause subsequent formatting steps to crash; the workspace filtering logic uses a fragile substring check for file: URIs; the new test in chrome_test.dart does not actually exercise the raw Chrome V8 coverage list parsing path; and an accumulator in test_util.dart should be explicitly typed to avoid runtime type errors.

Comment thread pkgs/coverage/lib/src/hitmap.dart
Comment thread pkgs/coverage/bin/test_with_coverage.dart
Comment thread pkgs/coverage/test/chrome_test.dart
Comment thread pkgs/coverage/test/test_util.dart Outdated
@kevmoo

kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@kevmoo

kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for collecting and formatting Web (V8 / Chrome) coverage reports in test_with_coverage using the -p/--platform flag, along with parsing raw Chrome V8 coverage JSON lists in HitMap.parseFiles. It also adds pre-flight verification for package:test and URI normalization. Feedback on the changes includes a suggestion to warn users if package_config.json is completely missing (rather than only when package:test is absent), and to simplify a redundant path containment check.

Comment thread pkgs/coverage/bin/test_with_coverage.dart
Comment thread pkgs/coverage/bin/test_with_coverage.dart Outdated
@kevmoo

kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for collecting and formatting Web (V8 / Chrome) coverage reports in test_with_coverage using a new -p / --platform flag. It also enables parsing of raw Chrome V8 coverage JSON lists in HitMap.parseFiles and introduces pre-flight verification using package_config. There are no review comments, so I have no additional feedback to provide.

@kevmoo

kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for collecting and formatting Web (V8 / Chrome) coverage reports via a new --platform flag, along with parsing raw Chrome V8 coverage JSON lists in HitMap.parseFiles. It also adds pre-flight package verification and URI normalization. The review feedback suggests several robustness and performance improvements, including using Uri.tryParse and checking pathSegments to avoid runtime crashes, using .whereType instead of .cast to safely parse JSON lists, and consistently converting scopes to a Set for O(1) lookups.

Comment thread pkgs/coverage/bin/test_with_coverage.dart
Comment thread pkgs/coverage/lib/src/hitmap.dart
Comment thread pkgs/coverage/bin/test_with_coverage.dart Outdated
@kevmoo

kevmoo commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Health

Unused Dependencies ✔️
Package Status
coverage ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
coverage Non-Breaking 1.15.1 1.16.0-wip 1.16.0-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

Coverage ⚠️
File Coverage
pkgs/coverage/benchmark/many_isolates.dart 💔 Not covered
pkgs/coverage/benchmark/run_benchmarks.dart 💔 Not covered
pkgs/coverage/bin/collect_coverage.dart 💔 Not covered
pkgs/coverage/bin/format_coverage.dart 💔 Not covered
pkgs/coverage/bin/test_with_coverage.dart 💔 Not covered
pkgs/coverage/lib/src/chrome.dart 💚 98 % ⬆️ 0 %
pkgs/coverage/lib/src/collect.dart 💔 84 % ⬇️ 3 %
pkgs/coverage/lib/src/coverage_options.dart 💚 100 %
pkgs/coverage/lib/src/coverage_percentage.dart 💚 100 %
pkgs/coverage/lib/src/formatter.dart 💚 97 % ⬆️ 0 %
pkgs/coverage/lib/src/hitmap.dart 💔 91 % ⬇️ 1 %
pkgs/coverage/lib/src/isolate_paused_listener.dart 💔 97 % ⬇️ 1 %
pkgs/coverage/lib/src/resolver.dart 💚 95 % ⬆️ 0 %
pkgs/coverage/lib/src/run_and_collect.dart 💚 69 %
pkgs/coverage/lib/src/util.dart 💚 100 %

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

This check can be disabled by tagging the PR with skip-license-check.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@kevmoo

kevmoo commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

I'm breaking this up into many PRs. First one: #2452

@kevmoo
kevmoo marked this pull request as draft July 2, 2026 06:04
@kevmoo

kevmoo commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

📌 Plan: Splitting PRs for Reviewability

To make code review as clean and focused as possible, the work on this branch is being split into three stacked/sequential PRs:

  1. PR 0 (Infra & Maintenance): fix(coverage): document RPC error codes 105/106 and memoize test hitmap process #2452
    • Documents RPC error codes 105/106 in isolate_paused_listener.dart.
    • Memoizes _getHitMap() process execution in lcov_test.dart, accelerating test suite speed from 2.5 minutes to 8 seconds.
  2. PR 1 (SDK 3.9 Bump): (Upcoming)
    • Bumps minimum Dart SDK constraint to ^3.9.0.
    • Applies Dart 3.9 formatter updates & line hitmap expectation updates.
  3. PR 2 (Web Coverage Feature): This PR (feat(coverage): support web coverage reports in test_with_coverage #2448)
    • Focuses purely on Web (Chrome) coverage generation support in test_with_coverage.

@mosuem

mosuem commented Jul 27, 2026

Copy link
Copy Markdown
Member

📌 Plan: Splitting PRs for Reviewability

To make code review as clean and focused as possible, the work on this branch is being split into three stacked/sequential PRs:

Does this mean this one can be closed @kevmoo ?

@kevmoo

kevmoo commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Can we keep it open for one more week? So I can track this who arc?

@mosuem

mosuem commented Jul 28, 2026

Copy link
Copy Markdown
Member

Sure, I was just looking through the PRs to clean stuff up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:coverage type-infra A repository infrastructure change or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[coverage] Support collecting and formatting Web (V8 / Chrome) coverage reports 'pub run test -p chrome' and '--coverage=coverage' hangs

2 participants