mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Throw an exception if flutter run fails during a microbenchmark (#9061)
This commit is contained in:
parent
0ec3ffb4bc
commit
f7d0aa03f8
@ -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) {
|
|||||||
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) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user