-
Notifications
You must be signed in to change notification settings - Fork 50
Added a tool to find uncovered files (#529) #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
This needs a test. Also, there's a merge conflict in format_coverage.dart that will need to be resolved before the github CI can be run
@@ -196,6 +200,8 @@ Environment parseArgs(List<String> arguments, CoverageOptions defaultOptions) { | |||
help: 'check for coverage ignore comments.' | |||
' Not supported in web coverage.', | |||
) | |||
..addFlag('include-uncovered', |
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.
This shouldn't be a bool flag. It should be a multi-option that accepts glob patterns, like ignore-files
. Then the includeUncovered
function passed to the formatter can check if the path
matches any of the globs.
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.
Ok ...got it...
I will change that.
@@ -193,8 +258,98 @@ extension FileHitMapsFormatter on Map<String, HitMap> { | |||
} | |||
} | |||
|
|||
if (includeUncovered != null) { |
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.
Duplicated code with the stuff on line 136
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.
Oops!! 😅
Ohh yes.. |
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
Overview
This PR adds support for a new --include-uncovered flag in format_coverage.dart, allowing uncovered Dart files (i.e., those with no test coverage) to be included in the LCOV output. Solving the issue (#529)
This is what I did:
format_coverage.dart
to parse--include-uncovered
flag.formatter.dart
to pass the logic and format the LCOV to include files that are not covered by coverage.Key changes in
formatter.dart
:import 'dart:io';
import 'package:yaml/yaml.dart';
required to scan all files in the directory and compare it with the covered files.formatLcov
andprettyprint
:bool Function(String path)? includeUncovered,
_findAllDartFiles
: to scan all files in the directory.getPackageName
: to get package.toPackageUri
: to convert the file paths into package uri for checking if the file is included or not.Testing:
CLI cmd:
dart run coverage:format_coverage --lcov --in=coverage --out=[lcov.info](http://lcov.info/) --report-on=lib --include-uncovered
example:
Before implementation:
as utils.dart didn't had any coresponding tests, it was not included in the LCOV.
After implementation:
utils.dart was included in the LCOV with 0 lines hit.
Conclusion:
--include-uncovered
is successfully working as expected.Feedback:
Please let me know if any changes or refinements are needed.
Thank you!