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 {
/// This will not start any collection tasks. It us up to the caller of to
/// call [collectCoverage] for each process first.
String finalizeCoverage({
String Function(Map<String, coverage.HitMap> hitmap) formatter,
coverage.Resolver resolver,
Directory coverageDirectory,
}) {
if (_globalHitmap == null) {
return null;
}
resolver ??= coverage.Resolver(packagesPath: packagesPath);
final String packagePath = globals.fs.currentDirectory.path;
final List<String> reportOn = coverageDirectory == null
? <String>[globals.fs.path.join(packagePath, 'lib')]
: <String>[coverageDirectory.path];
final String result = _globalHitmap.formatLcov(resolver, reportOn: reportOn, basePath: packagePath);
if (formatter == null) {
resolver ??= coverage.Resolver(packagesPath: packagesPath);
final String packagePath = globals.fs.currentDirectory.path;
final List<String> reportOn = coverageDirectory == null
? <String>[globals.fs.path.join(packagePath, 'lib')]
: <String>[coverageDirectory.path];
formatter = (Map<String, coverage.HitMap> hitmap) => hitmap
.formatLcov(resolver, reportOn: reportOn, basePath: packagePath);
}
final String result = formatter(_globalHitmap);
_globalHitmap = null;
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