Skip to content

Add --coverage-lcov and --branch-coverage options #2517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Jul 9, 2025

  • Add a --coverage-lcov option to dart test, which takes a filename. This option works like --coverage, except that instead of generating multiple JSON reports, it generates a single LCOV report.
    • Aside from plumbing, the main change is in pkgs/test_core/lib/src/runner/coverage.dart's coverage collection functions, and how pkgs/test_core/lib/src/runner/engine.dart invokes them.
    • In LCOV mode, writeCoverage is still called, but doesn't write the JSON file. Instead it returns the generated coverage report. The Engine merges all these coverage reports into _allCoverageData, and once all the tests are done it calls writeCoverageLcov to finalize the report and write it to the lcov file.
  • Add a --branch-coverage flag that is plumbed through to collect's branchCoverage param.
  • Update the README to mention the --coverage-lcov workflow.
  • Set collect's scopedOutput param to the current package name. This front load the filtering of the coverage report, improving performance by removing unnecessary information as early as possible.
  • The test util runPub was using the deprecated standalone pub tool. This didn't cause problems because it was dead code. But I had to use it in the new tests, so I updated it to use dart pub.

Fixes #2511

Copy link

github-actions bot commented Jul 9, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

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

@liamappelbe

This comment was marked as resolved.

@liamappelbe liamappelbe changed the title WIP: Add --coverage-lcov and --branch-cov options Add --coverage-lcov and --branch-cov options Jul 11, 2025
@liamappelbe liamappelbe marked this pull request as ready for review July 11, 2025 04:23
@liamappelbe liamappelbe requested a review from a team as a code owner July 11, 2025 04:23
@liamappelbe liamappelbe changed the title Add --coverage-lcov and --branch-cov options Add --coverage-lcov and --branch-coverage options Jul 13, 2025
@liamappelbe liamappelbe requested a review from jakemac53 July 14, 2025 03:00
@liamappelbe
Copy link
Contributor Author

The remaining test failures don't seem related to this PR

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

Successfully merging this pull request may close these issues.

Align dart test --coverage with package:coverage's test_with_coverage and flutter test --coverage
1 participant