Unverified Commit 1d2f9c97 authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Reintroduce the ability to override the coverage formatter (#100320)

parent 25fc01ac
...@@ -123,18 +123,23 @@ class CoverageCollector extends TestWatcher { ...@@ -123,18 +123,23 @@ class CoverageCollector extends TestWatcher {
/// This will not start any collection tasks. It us up to the caller of to /// This will not start any collection tasks. It us up to the caller of to
/// call [collectCoverage] for each process first. /// call [collectCoverage] for each process first.
String finalizeCoverage({ String finalizeCoverage({
String Function(Map<String, coverage.HitMap> hitmap) formatter,
coverage.Resolver resolver, coverage.Resolver resolver,
Directory coverageDirectory, Directory coverageDirectory,
}) { }) {
if (_globalHitmap == null) { if (_globalHitmap == null) {
return null; return null;
} }
resolver ??= coverage.Resolver(packagesPath: packagesPath); if (formatter == null) {
final String packagePath = globals.fs.currentDirectory.path; resolver ??= coverage.Resolver(packagesPath: packagesPath);
final List<String> reportOn = coverageDirectory == null final String packagePath = globals.fs.currentDirectory.path;
? <String>[globals.fs.path.join(packagePath, 'lib')] final List<String> reportOn = coverageDirectory == null
: <String>[coverageDirectory.path]; ? <String>[globals.fs.path.join(packagePath, 'lib')]
final String result = _globalHitmap.formatLcov(resolver, reportOn: reportOn, basePath: packagePath); : <String>[coverageDirectory.path];
formatter = (Map<String, coverage.HitMap> hitmap) => hitmap
.formatLcov(resolver, reportOn: reportOn, basePath: packagePath);
}
final String result = formatter(_globalHitmap);
_globalHitmap = null; _globalHitmap = null;
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment