Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Apply --scope-output filters after getSourceReport #498

Merged
merged 6 commits into from
Jul 31, 2024
Merged

Conversation

liamappelbe
Copy link
Contributor

The --scope-output filters are passed to getSourceReport.libraryFilters, but there are cases where the report can contain ranges that bypass the filter. This happens when the range has a different library than their enclosing function/class (eg mixins).

To fix this we just need to re-apply the filters to the reported ranges. It's still important to pass the filters to getSourceReport, because these are pretty rare edge cases and the filtering is still a useful optimisation to reduce the size of the report.

Fixes dart-lang/tools#530

@liamappelbe liamappelbe requested a review from bkonyi July 30, 2024 04:04
@liamappelbe liamappelbe marked this pull request as ready for review July 30, 2024 04:04
@coveralls
Copy link

coveralls commented Jul 30, 2024

Coverage Status

coverage: 93.74% (+0.04%) from 93.698%
when pulling 6ce09b9 on fix495
into f2e52fb on master.

@liamappelbe liamappelbe changed the title WIP: Apply --scope-output filters after getSourceReport Apply --scope-output filters after getSourceReport Jul 30, 2024
@liamappelbe liamappelbe enabled auto-merge (squash) July 30, 2024 04:35
if (isEmpty) return true;
final scriptUri = Uri.parse(scriptUriString);
if (scriptUri.scheme != 'package') return false;
final scope = scriptUri.path.split('/').first;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: would final scope = scriptUri.pathSegments.first achieve the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

extension _ScopedOutput on Set<String> {
bool includesScript(String? scriptUriString) {
if (scriptUriString == null) return false;
if (isEmpty) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this return false if the set is empty? If not, can you leave a comment explaining why we're considering an empty set to include all scripts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! That makes sense.

when(service.getSourceReport('isolate', ['Coverage'],
forceCompile: true,
reportLines: true,
libraryFilters: ['package:foo/']))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ubernit: consider adding trailing commas for formatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@liamappelbe liamappelbe requested a review from bkonyi July 30, 2024 23:08
extension _ScopedOutput on Set<String> {
bool includesScript(String? scriptUriString) {
if (scriptUriString == null) return false;
if (isEmpty) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! That makes sense.

@liamappelbe liamappelbe merged commit 5ccac01 into master Jul 31, 2024
9 checks passed
@liamappelbe liamappelbe deleted the fix495 branch July 31, 2024 14:36
mosuem pushed a commit to dart-lang/tools that referenced this pull request Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

--scope-output does not work
3 participants