-
Notifications
You must be signed in to change notification settings - Fork 54
Apply --scope-output
filters after getSourceReport
#498
Conversation
--scope-output
filters after getSourceReport
--scope-output
filters after getSourceReport
lib/src/collect.dart
Outdated
if (isEmpty) return true; | ||
final scriptUri = Uri.parse(scriptUriString); | ||
if (scriptUri.scheme != 'package') return false; | ||
final scope = scriptUri.path.split('/').first; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That makes sense.
test/collect_coverage_mock_test.dart
Outdated
when(service.getSourceReport('isolate', ['Coverage'], | ||
forceCompile: true, | ||
reportLines: true, | ||
libraryFilters: ['package:foo/'])) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That makes sense.
The
--scope-output
filters are passed togetSourceReport.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