diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index de973e7236..43dfc86bcd 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -18,7 +18,7 @@ class CoverageCollector extends TestWatcher { Map _globalHitmap; @override - Future onFinishedTests(ProcessEvent event) async { + Future onFinishedTest(ProcessEvent event) async { printTrace('test ${event.childIndex}: collecting coverage'); await collectCoverage(event.process, event.observatoryUri); } diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 1eace64ce1..f591ead33b 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -497,9 +497,21 @@ class _FlutterPlatform extends PlatformPlugin { break; } - if (subprocessActive && watcher != null) { - await watcher.onFinishedTests( - new ProcessEvent(ourTestCount, process, processObservatoryUri)); + if (watcher != null) { + switch (initialResult) { + case _InitialResult.crashed: + await watcher.onTestCrashed(new ProcessEvent(ourTestCount, process)); + break; + case _InitialResult.timedOut: + await watcher.onTestTimedOut(new ProcessEvent(ourTestCount, process)); + break; + case _InitialResult.connected: + if (subprocessActive) { + await watcher.onFinishedTest( + new ProcessEvent(ourTestCount, process, processObservatoryUri)); + } + break; + } } } catch (error, stack) { printTrace('test $ourTestCount: error caught during test; ${controllerSinkClosed ? "reporting to console" : "sending to test framework"}'); diff --git a/packages/flutter_tools/lib/src/test/watcher.dart b/packages/flutter_tools/lib/src/test/watcher.dart index 497531592a..e03326f96a 100644 --- a/packages/flutter_tools/lib/src/test/watcher.dart +++ b/packages/flutter_tools/lib/src/test/watcher.dart @@ -6,7 +6,7 @@ import 'dart:async'; import '../base/io.dart' show Process; /// Callbacks for reporting progress while running tests. -class TestWatcher { +abstract class TestWatcher { /// Called after a child process starts. /// /// If startPaused was true, the caller needs to resume in Observatory to @@ -17,12 +17,19 @@ class TestWatcher { /// /// The child process won't exit until this method completes. /// Not called if the process died. - Future onFinishedTests(ProcessEvent event) async {} + Future onFinishedTest(ProcessEvent event) async {} + + /// Called when the test process crashed before connecting to test harness. + Future onTestCrashed(ProcessEvent event) async {} + + /// Called if we timed out waiting for the test process to connect to test + /// harness. + Future onTestTimedOut(ProcessEvent event) async {} } /// Describes a child process started during testing. class ProcessEvent { - ProcessEvent(this.childIndex, this.process, this.observatoryUri); + ProcessEvent(this.childIndex, this.process, [this.observatoryUri]); /// The index assigned when the child process was launched. ///