Unverified Commit 8b0227b4 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

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