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
This commit is contained in:
committed by
GitHub
parent
2243c42ebc
commit
0a9b358e3d
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user