Unverified Commit febce13a authored by Dan Field's avatar Dan Field Committed by GitHub

Make retry logic more permissive for network errors (#83965)

parent 2d8d1052
......@@ -50,8 +50,8 @@ enum GradleBuildStatus {
retryWithAarPlugins,
}
/// Returns a simple test function that evaluates to [true] if
/// [errorMessage] is contained in the error message.
/// Returns a simple test function that evaluates to `true` if at least one of
/// `errorMessages` is contained in the error message.
GradleErrorTest _lineMatcher(List<String> errorMessages) {
return (String line) {
return errorMessages.any((String errorMessage) => line.contains(errorMessage));
......@@ -118,7 +118,7 @@ final GradleHandledError networkErrorHandler = GradleHandledError(
'javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake',
'java.net.SocketException: Connection reset',
'java.io.FileNotFoundException',
'Gateway Time-out'
"> Could not get resource 'http",
]),
handler: ({
required String line,
......
......@@ -298,6 +298,38 @@ A problem occurred configuring root project 'android'.
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('retries if Gradle could not get a resource (non-Gateway)', () async {
const String errorMessage = '''
* Error running Gradle:
Exit code 1 from: /home/travis/build/flutter/flutter sdk/examples/flutter_gallery/android/gradlew app:properties:
Starting a Gradle Daemon (subsequent builds will be faster)
Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.1.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.1.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Remote host closed connection during handshake''';
expect(formatTestErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
expect(testLogger.errorText,
contains(
'Gradle threw an error while downloading artifacts from the network. '
'Retrying to download...'
)
);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
});
group('permission errors', () {
......
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