Unverified Commit 198e40c9 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] retry the driver launch of the application up to 3 times. (#68334)

We'd like to see how many of these flakes are transient and how many involve the device/machine getting temporarily wedged. Add a retry with no delay to see if it is possible to add sufficient error handling to startApp/installApp to handle this.
parent 7b04435a
......@@ -246,7 +246,19 @@ class DriveCommand extends RunCommandBase {
webUri = residentRunner.uri;
}
final LaunchResult result = await appStarter(this, webUri, package, applicationBinary != null);
// Attempt to launch the application up to 3 times, to validate whether it
// is possible to reduce flakiness by hardnening the launch code.
int attempt = 0;
LaunchResult result;
while (attempt < 3) {
// On attempts past 1, assume the application is built correctly and re-use it.
result = await appStarter(this, webUri, package, applicationBinary != null || attempt > 0);
if (result != null) {
break;
}
attempt += 1;
globals.printError('Application failed to start on attempt: $attempt');
}
if (result == null) {
throwToolExit('Application failed to start. Will not run test. Quitting.', exitCode: 1);
}
......
......@@ -99,7 +99,7 @@ void main() {
testUsingContext('returns 1 when app fails to run', () async {
testDeviceManager.addDevice(MockDevice());
appStarter = expectAsync4((DriveCommand command, Uri webUri, ApplicationPackage package, bool prebuiltApplication) async => null);
appStarter = expectAsync4((DriveCommand command, Uri webUri, ApplicationPackage package, bool prebuiltApplication) async => null, count: 3);
final String testApp = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e.dart');
final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
......
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