Reintroduce the ability to override the coverage formatter (#100320)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user