Unverified Commit d2ba83d4 authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Use libraryFilters flag to speed up coverage collection (#104122)

* Use libraryFilters flag to speed up coverage collection

* Allow libraryNames to be null

* Unconditionally enable the reportLines flag

* Fix analysis errors
parent d9f3acb1
...@@ -112,16 +112,13 @@ Future<void> run(List<String> args) async { ...@@ -112,16 +112,13 @@ Future<void> run(List<String> args) async {
Directory testDirectory; Directory testDirectory;
CoverageCollector collector; CoverageCollector collector;
if (argResults['coverage'] as bool) { if (argResults['coverage'] as bool) {
// If we have a specified coverage directory then accept all libraries by
// setting libraryNames to null.
final Set<String> libraryNames = coverageDirectory != null ? null :
<String>{FlutterProject.current().manifest.appName};
collector = CoverageCollector( collector = CoverageCollector(
packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String)), packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String)),
libraryPredicate: (String libraryName) { libraryNames: libraryNames);
// If we have a specified coverage directory then accept all libraries.
if (coverageDirectory != null) {
return true;
}
final String projectName = FlutterProject.current().manifest.appName;
return libraryName.contains(projectName);
});
if (!argResults.options.contains(_kOptionTestDirectory)) { if (!argResults.options.contains(_kOptionTestDirectory)) {
throwToolExit('Use of --coverage requires setting --test-directory'); throwToolExit('Use of --coverage requires setting --test-directory');
} }
......
...@@ -380,7 +380,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -380,7 +380,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
final String projectName = flutterProject.manifest.appName; final String projectName = flutterProject.manifest.appName;
collector = CoverageCollector( collector = CoverageCollector(
verbose: !machine, verbose: !machine,
libraryPredicate: (String libraryName) => libraryName.contains(projectName), libraryNames: <String>{projectName},
packagesPath: buildInfo.packagesPath packagesPath: buildInfo.packagesPath
); );
} }
......
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