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; }