You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes coverage is gathered from external packages even when --scope-output flag is used and set to the name of the app's package.
Reproduction
Create a new dart project with dart create minimal-sample
Add equatable package: dart pub add equatable
Replace the code inside lib/minimal_sample.dart with the code below:
import 'package:equatable/equatable.dart';
class SomeClass with EquatableMixin {
@override
List<Object?> get props => [];
}
int calculate() {
return 6 * 7;
}
run
dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=8181 test &
dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:8181/ -o coverage/coverage.json --resume-isolates --scope-output=minimal_sample
After performing the steps above, the generated coverage/coverage.json looks like this:
There are 2 ways of filtering the output, collect_coverage's --scope-output flag, and format_coverage's --report-on flag. scope-output is passed to the VM, and used to filter which libraries are collected. Due to the way mixins work (essentially copy/pasting their code into the child class), when it reports on SomeClass, it also reports on EquatableMixin. report-on works purely within package:coverage, and doesn't understand language constructs like mixins, so it will filter out EquatableMixin.
I can probably fix the VM logic to be stricter about applying the filters to mixins. In the meantime, you can use --report-on to further filter the result.
Took another look at how the source report is implemented in the VM, and it's not going to be easy to fix it in there. Better to apply the filters to the report returned by the VM (in addition to passing the filters to the VM).
Sometimes coverage is gathered from external packages even when
--scope-output
flag is used and set to the name of the app's package.Reproduction
dart create minimal-sample
dart pub add equatable
lib/minimal_sample.dart
with the code below:After performing the steps above, the generated
coverage/coverage.json
looks like this:I use Dart SDK 3.3.3.
The text was updated successfully, but these errors were encountered: