Skip to content

Conversation

@liamappelbe
Copy link
Contributor

Fixes dart-lang/tools#2269

The bug is that when dart test --coverage... is run in a package that's part of a workspace, the default coverage filter is set to the name of the workspace, rather than the package under test. In package:coverage I solved this by searching for all the nested packages, and using those as the default filter. Another approach would be to restrict the default filter to only include the package under test, but I think users are more likely to want all the workspace's packages included in the report.

This change introduces a dependency on package:pubspec_parse. Hopefully that's ok.

@liamappelbe liamappelbe requested a review from a team as a code owner December 5, 2025 01:20
@liamappelbe liamappelbe requested a review from natebosch December 5, 2025 01:22
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

PR Health

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.

final pubspec = Pubspec.parse(yaml, sourceUrl: pubspecUri);
results.add(pubspec.name);
for (final workspace in pubspec.workspace ?? <String>[]) {
_getAllWorkspaceNames(packageRoot.resolve('$workspace/'), results);
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to be recursive? Each package in a workspace should only contribute one package to the set...

Copy link
Contributor Author

@liamappelbe liamappelbe Dec 10, 2025

Choose a reason for hiding this comment

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

Workspaces can contain workspaces, and can form a tree. I asked the pub folks about this edge case when I was building this feature for package:coverage, and they said it's an intended (though uncommon) use case.

@liamappelbe liamappelbe merged commit 462b474 into master Dec 11, 2025
59 checks passed
@liamappelbe liamappelbe deleted the workspace_coverage branch December 11, 2025 01:59
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.

Test coverage without --coverage-package doesn't work correctly (in pub workspaces?)

2 participants