Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly pass on gradle exit code (#71484) #71582

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/flutter_tools/lib/src/android/gradle.dart
Expand Up @@ -645,8 +645,8 @@ Future<void> buildGradleAar({
globals.printStatus(result.stdout, wrap: false);
globals.printError(result.stderr, wrap: false);
throwToolExit(
'Gradle task $aarTask failed with exit code $exitCode.',
exitCode: exitCode,
'Gradle task $aarTask failed with exit code ${result.exitCode}.',
exitCode: result.exitCode,
);
}
final Directory repoDirectory = getRepoDirectory(outputDirectory);
Expand Down
46 changes: 46 additions & 0 deletions packages/flutter_tools/test/general.shard/android/gradle_test.dart
Expand Up @@ -1704,6 +1704,52 @@ plugin1=${plugin1.path}
ProcessManager: () => mockProcessManager,
});

testUsingContext('gradle exit code is properly passed on', () async {
final File manifestFile = fileSystem.file('pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync('''
flutter:
module:
androidPackage: com.example.test
'''
);

fileSystem.file('.android/gradlew').createSync(recursive: true);

fileSystem.file('.android/gradle.properties')
.writeAsStringSync('irrelevant');

fileSystem.file('.android/build.gradle')
.createSync(recursive: true);

// Let any process start. Assert after.
when(mockProcessManager.run(
any,
environment: anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory'),
)).thenAnswer((_) async => ProcessResult(1, 108, '', ''));

fileSystem.directory('build/outputs/repo').createSync(recursive: true);

await expectLater(() async =>
await buildGradleAar(
androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null, treeShakeIcons: false)),
project: FlutterProject.current(),
outputDirectory: fileSystem.directory('build/'),
target: '',
buildNumber: '1.0',
)
, throwsToolExit(exitCode: 108, message: 'Gradle task assembleAarRelease failed with exit code 108.'));

}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
AndroidStudio: () => mockAndroidStudio,
Cache: () => cache,
Platform: () => android,
FileSystem: () => fileSystem,
ProcessManager: () => mockProcessManager,
});

testUsingContext('build apk uses selected local engine,the engine abi is arm', () async {
when(mockArtifacts.getArtifactPath(
Artifact.flutterFramework,
Expand Down