From f7d0aa03f8a472b64dce2a3b42538638b864715c Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 28 Mar 2017 15:46:53 -0700 Subject: [PATCH] Throw an exception if flutter run fails during a microbenchmark (#9061) --- dev/devicelab/lib/tasks/microbenchmarks.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index df8e47fb021..7ddf49e116e 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -79,6 +79,7 @@ Future> _readJsonResults(Process process) { StreamSubscription stdoutSub; int prefixLength = 0; + bool processKilled = false; stdoutSub = process.stdout .transform(const Utf8Decoder()) .transform(const LineSplitter()) @@ -94,6 +95,7 @@ Future> _readJsonResults(Process process) { if (line.contains(jsonEnd)) { jsonStarted = false; stdoutSub.cancel(); + processKilled = true; process.kill(ProcessSignal.SIGINT); // flutter run doesn't quit automatically completer.complete(JSON.decode(jsonBuf.toString())); return; @@ -103,5 +105,11 @@ Future> _readJsonResults(Process process) { jsonBuf.writeln(line.substring(prefixLength)); }); + process.exitCode.then((int code) { + if (!processKilled && code != 0) { + completer.completeError('flutter run failed: exit code=$code'); + } + }); + return completer.future; }