Unverified Commit 28cb589c authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

make flutterProject option of CoverageCollector optional (#31074)

parent b0937a1e
...@@ -116,7 +116,10 @@ Future<void> run(List<String> args) async { ...@@ -116,7 +116,10 @@ Future<void> run(List<String> args) async {
Directory testDirectory; Directory testDirectory;
CoverageCollector collector; CoverageCollector collector;
if (argResults['coverage']) { if (argResults['coverage']) {
collector = CoverageCollector(await FlutterProject.current(), coverageDirectory: coverageDirectory); collector = CoverageCollector(
flutterProject: await FlutterProject.current(),
coverageDirectory: coverageDirectory,
);
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');
} }
......
...@@ -149,7 +149,9 @@ class TestCommand extends FastFlutterCommand { ...@@ -149,7 +149,9 @@ class TestCommand extends FastFlutterCommand {
CoverageCollector collector; CoverageCollector collector;
if (argResults['coverage'] || argResults['merge-coverage']) { if (argResults['coverage'] || argResults['merge-coverage']) {
collector = CoverageCollector(await FlutterProject.current()); collector = CoverageCollector(
flutterProject: await FlutterProject.current(),
);
} }
final bool machine = argResults['machine']; final bool machine = argResults['machine'];
......
...@@ -21,7 +21,7 @@ import 'watcher.dart'; ...@@ -21,7 +21,7 @@ import 'watcher.dart';
/// A class that's used to collect coverage data during tests. /// A class that's used to collect coverage data during tests.
class CoverageCollector extends TestWatcher { class CoverageCollector extends TestWatcher {
CoverageCollector(this.flutterProject, {this.coverageDirectory}); CoverageCollector({this.flutterProject, this.coverageDirectory});
Map<String, dynamic> _globalHitmap; Map<String, dynamic> _globalHitmap;
final Directory coverageDirectory; final Directory coverageDirectory;
...@@ -63,6 +63,9 @@ class CoverageCollector extends TestWatcher { ...@@ -63,6 +63,9 @@ class CoverageCollector extends TestWatcher {
if (coverageDirectory != null) { if (coverageDirectory != null) {
return true; return true;
} }
if (flutterProject == null) {
return true;
}
return libraryName.contains(flutterProject.manifest.appName); return libraryName.contains(flutterProject.manifest.appName);
}) })
.then<void>((Map<String, dynamic> result) { .then<void>((Map<String, dynamic> 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