From 8b0227b4a37041d57591b293482a984b84d1b13f Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 28 Aug 2018 18:26:46 +0100 Subject: [PATCH] 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. --- .../test/integration/test_driver.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/test/integration/test_driver.dart b/packages/flutter_tools/test/integration/test_driver.dart index e67fe89229..091df6453d 100644 --- a/packages/flutter_tools/test/integration/test_driver.dart +++ b/packages/flutter_tools/test/integration/test_driver.dart @@ -89,7 +89,10 @@ class FlutterTestDriver { workingDirectory: _projectFolder.path, environment: {'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', - {'appId': _currentRunningAppId} - ).timeout( + await Future.any(>[ + _proc.exitCode, + _sendRequest( + 'app.stop', + {'appId': _currentRunningAppId} + ), + ]).timeout( quitTimeout, onTimeout: () { _debugPrint('app.stop did not return within $quitTimeout'); } );