Throw an exception if flutter run fails during a microbenchmark (#9061)

This commit is contained in:
Jason Simmons 2017-03-28 15:46:53 -07:00 committed by GitHub
parent 0ec3ffb4bc
commit f7d0aa03f8

View File

@ -79,6 +79,7 @@ Future<Map<String, double>> _readJsonResults(Process process) {
StreamSubscription<String> stdoutSub;
int prefixLength = 0;
bool processKilled = false;
stdoutSub = process.stdout
.transform(const Utf8Decoder())
.transform(const LineSplitter())
@ -94,6 +95,7 @@ Future<Map<String, double>> _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<Map<String, double>> _readJsonResults(Process process) {
jsonBuf.writeln(line.substring(prefixLength));
});
process.exitCode.then<int>((int code) {
if (!processKilled && code != 0) {
completer.completeError('flutter run failed: exit code=$code');
}
});
return completer.future;
}