Skip to content

Commit

Permalink
Ignore abstract methods (#412)
Browse files Browse the repository at this point in the history
* Fix branch coverage test

* Ignore implicit functions in function coverage

* Add a dedicated function coverage test.

* Fix analysis

* Ignore abstract functions

* Use the new vm_service version

* Fix test

* vm_service abstract update was actually a minor version bump

* Remove deprecated analysis option

* Fix function_coverage_test on older SDKs
  • Loading branch information
liamappelbe committed Jul 25, 2022
1 parent 7574815 commit 6a6fc15
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ linter:
- control_flow_in_finally
- empty_statements
- hash_and_equals
- invariant_booleans
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- literal_only_boolean_expressions
Expand Down
2 changes: 1 addition & 1 deletion lib/src/collect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Future<List<Map<String, dynamic>>> _getCoverageJson(

Future<void> processFunction(FuncRef funcRef) async {
final func = await service.getObject(isolateRef.id!, funcRef.id!) as Func;
if (func.implicit ?? false) {
if ((func.implicit ?? false) || (func.isAbstract ?? false)) {
return;
}
final location = func.location;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
path: ^1.8.0
source_maps: ^0.10.10
stack_trace: ^1.10.0
vm_service: ^9.0.0
vm_service: ^9.2.0

dev_dependencies:
build_runner: ^2.1.10
Expand Down
4 changes: 2 additions & 2 deletions test/function_coverage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main() {
final isolateFile = hitMap[_sampleAppFileUri]!;
expect(isolateFile.funcHits, {
7: 1,
12: 0, // TODO(#398): This abstract method should be ignored.
if (!platformVersionCheck(2, 19)) 12: 0,
16: 1,
21: 1,
25: 1,
Expand All @@ -43,7 +43,7 @@ void main() {
});
expect(isolateFile.funcNames, {
7: 'normalFunction',
12: 'BaseClass.abstractMethod',
if (!platformVersionCheck(2, 19)) 12: 'BaseClass.abstractMethod',
16: 'SomeClass.SomeClass',
21: 'SomeClass.normalMethod',
25: 'SomeClass.staticMethod',
Expand Down

0 comments on commit 6a6fc15

Please sign in to comment.