Don't time out if process terminates when told to stop (#21103)

* Don't time out if process terminates when told to stop but response was not processed

While trying to reproduce #20822 I found a condition where the app may quit before the `app.stop` response is received but this code (which is called in integration test teardown) would sit around waiting and time out. With this change, the process exit is considered a valid response to the stop request.

* Add process exit to log for better errors in failures

This log can be turned on for debugging but is also dumped when a test fails (in certain conditions). With this in the log, it'll be clear if the timeout is because we're waiting for an event but the process quit.
This commit is contained in:
Danny Tuppeny
2018-08-28 18:26:46 +01:00
committed by GitHub
parent 5eebfeb345
commit 8b0227b4a3

View File

@@ -89,7 +89,10 @@ class FlutterTestDriver {
workingDirectory: _projectFolder.path,
environment: <String, String>{'FLUTTER_TEST': 'true'});
_proc.exitCode.then((_) => _hasExited = true);
_proc.exitCode.then((int code) {
_debugPrint('Process exited ($code)');
_hasExited = true;
});
_transformToLines(_proc.stdout).listen((String line) => _stdout.add(line));
_transformToLines(_proc.stderr).listen((String line) => _stderr.add(line));
@@ -166,10 +169,13 @@ class FlutterTestDriver {
}
if (_currentRunningAppId != null) {
_debugPrint('Stopping app');
await _sendRequest(
'app.stop',
<String, dynamic>{'appId': _currentRunningAppId}
).timeout(
await Future.any<void>(<Future<void>>[
_proc.exitCode,
_sendRequest(
'app.stop',
<String, dynamic>{'appId': _currentRunningAppId}
),
]).timeout(
quitTimeout,
onTimeout: () { _debugPrint('app.stop did not return within $quitTimeout'); }
);