Commit f7d0aa03 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

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

parent 0ec3ffb4
...@@ -79,6 +79,7 @@ Future<Map<String, double>> _readJsonResults(Process process) { ...@@ -79,6 +79,7 @@ Future<Map<String, double>> _readJsonResults(Process process) {
StreamSubscription<String> stdoutSub; StreamSubscription<String> stdoutSub;
int prefixLength = 0; int prefixLength = 0;
bool processKilled = false;
stdoutSub = process.stdout stdoutSub = process.stdout
.transform(const Utf8Decoder()) .transform(const Utf8Decoder())
.transform(const LineSplitter()) .transform(const LineSplitter())
...@@ -94,6 +95,7 @@ Future<Map<String, double>> _readJsonResults(Process process) { ...@@ -94,6 +95,7 @@ Future<Map<String, double>> _readJsonResults(Process process) {
if (line.contains(jsonEnd)) { if (line.contains(jsonEnd)) {
jsonStarted = false; jsonStarted = false;
stdoutSub.cancel(); stdoutSub.cancel();
processKilled = true;
process.kill(ProcessSignal.SIGINT); // flutter run doesn't quit automatically process.kill(ProcessSignal.SIGINT); // flutter run doesn't quit automatically
completer.complete(JSON.decode(jsonBuf.toString())); completer.complete(JSON.decode(jsonBuf.toString()));
return; return;
...@@ -103,5 +105,11 @@ Future<Map<String, double>> _readJsonResults(Process process) { ...@@ -103,5 +105,11 @@ Future<Map<String, double>> _readJsonResults(Process process) {
jsonBuf.writeln(line.substring(prefixLength)); 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; return completer.future;
} }
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