Unverified Commit 0a9b358e authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Fix expression evaluation test leaking flutter_tester processes. (#51496)

* Fix expression evaluation test leaking flutter_tester processes.

Let flutter_tester process complete, wait for it completion, kill the test only if didn't complete on time.

* Type annotation
parent 2243c42e
......@@ -107,7 +107,7 @@ void batch2() {
}
Future<void> cleanProject() async {
await _flutter?.quit();
await _flutter?.waitForCompletion();
tryToDelete(tempDir);
}
......
......@@ -679,8 +679,6 @@ class FlutterTestTestDriver extends FlutterTestDriver {
'test',
'--disable-service-auth-codes',
'--machine',
'-d',
'flutter-tester',
], script: testFile, withDebugger: withDebugger, pauseOnExceptions: pauseOnExceptions, pidFile: pidFile, beforeStart: beforeStart);
}
......@@ -739,6 +737,29 @@ class FlutterTestTestDriver extends FlutterTestDriver {
return null;
}
}
Future<void> waitForCompletion() async {
final Completer<bool> done = Completer<bool>();
// Waiting for `{"success":true,"type":"done",...}` line indicating
// end of test run.
final StreamSubscription<String> subscription = _stdout.stream.listen(
(String line) async {
final Map<String, dynamic> json = _parseJsonResponse(line);
if (json != null && json['type'] != null && json['success'] != null) {
done.complete(json['type'] == 'done' && json['success'] == true);
}
});
await resume();
final Future<dynamic> timeoutFuture =
Future<dynamic>.delayed(defaultTimeout);
await Future.any<dynamic>(<Future<dynamic>>[done.future, timeoutFuture]);
await subscription.cancel();
if (!done.isCompleted) {
await quit();
}
}
}
Stream<String> transformToLines(Stream<List<int>> byteStream) {
......
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