diff --git a/dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart b/dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart index af5f89fdb86..01334b3600e 100644 --- a/dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart +++ b/dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart @@ -25,7 +25,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); + Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); checkCollectionContains([ ...flutterAssets, @@ -44,9 +44,7 @@ Future main() async { 'lib/x86/libapp.so', 'lib/x86_64/libapp.so', ], apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleRelease without explicit target platform'); await inDirectory(pluginProject.exampleAndroidPath, () { @@ -59,7 +57,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.releaseApkPath); + apkFiles = await getFilesInApk(pluginProject.releaseApkPath); checkCollectionContains([ ...flutterAssets, @@ -73,9 +71,7 @@ Future main() async { ], apkFiles); checkCollectionDoesNotContain(debugAssets, apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleRelease with target platform = android-arm, android-arm64'); await inDirectory(pluginProject.exampleAndroidPath, () { @@ -89,7 +85,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.releaseApkPath); + apkFiles = await getFilesInApk(pluginProject.releaseApkPath); checkCollectionContains([ ...flutterAssets, @@ -101,9 +97,7 @@ Future main() async { ], apkFiles); checkCollectionDoesNotContain(debugAssets, apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleRelease with ' 'target platform = android-arm, android-arm64 and split per ABI'); diff --git a/dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart b/dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart index 9c22442ea81..a61ec2fbe8d 100644 --- a/dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart +++ b/dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart @@ -27,7 +27,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); + Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); checkCollectionContains([ ...flutterAssets, @@ -45,9 +45,7 @@ Future main() async { 'lib/x86/libapp.so', 'lib/x86_64/libapp.so', ], apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleDebug with target platform = android-x86'); // This is used by `flutter run` await inDirectory(pluginProject.exampleAndroidPath, () { @@ -61,7 +59,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); + apkFiles = await getFilesInApk(pluginProject.debugApkPath); checkCollectionContains([ ...flutterAssets, @@ -77,9 +75,7 @@ Future main() async { 'lib/x86/libapp.so', 'lib/x86_64/libapp.so', ], apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleDebug with target platform = android-x64'); // This is used by `flutter run` @@ -94,7 +90,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.debugApkPath); + apkFiles = await getFilesInApk(pluginProject.debugApkPath); checkCollectionContains([ ...flutterAssets, @@ -110,9 +106,7 @@ Future main() async { 'lib/x86/libapp.so', 'lib/x86_64/libapp.so', ], apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleRelease with target platform = android-arm'); await inDirectory(pluginProject.exampleAndroidPath, () { @@ -126,7 +120,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.releaseApkPath); + apkFiles = await getFilesInApk(pluginProject.releaseApkPath); checkCollectionContains([ ...flutterAssets, @@ -140,9 +134,7 @@ Future main() async { 'lib/arm64-v8a/libflutter.so', 'lib/arm64-v8a/libapp.so', ], apkFiles); - }); - await runPluginProjectTest((FlutterPluginProject pluginProject) async { section('APK content for task assembleRelease with target platform = android-arm64'); await inDirectory(pluginProject.exampleAndroidPath, () { @@ -156,7 +148,7 @@ Future main() async { ); }); - final Iterable apkFiles = await getFilesInApk(pluginProject.releaseApkPath); + apkFiles = await getFilesInApk(pluginProject.releaseApkPath); checkCollectionContains([ ...flutterAssets, @@ -187,9 +179,7 @@ Future main() async { if (errorMessage != null) { throw TaskResult.failure(errorMessage); } - }); - await runProjectTest((FlutterProject project) async { section('gradlew assembleProfile'); await inDirectory(project.rootPath, () { return flutter( @@ -200,9 +190,7 @@ Future main() async { ], ); }); - }); - await runProjectTest((FlutterProject project) async { section('gradlew assembleLocal (custom debug build)'); await project.addCustomBuildType('local', initWith: 'debug'); await project.runGradleTask('assembleLocal'); @@ -263,7 +251,7 @@ Future main() async { await runProjectTest((FlutterProject project) async { section('gradlew on build script with error'); await project.introduceError(); - final ProcessResult result = await inDirectory(project.rootPath, () { + ProcessResult result = await inDirectory(project.rootPath, () { return executeFlutter('build', options: [ 'apk', '--release', @@ -273,7 +261,7 @@ Future main() async { if (result.exitCode == 0) throw failure( 'Gradle did not exit with error as expected', result); - final String output = '${result.stdout}\n${result.stderr}'; + String output = '${result.stdout}\n${result.stderr}'; if (output.contains('GradleException') || output.contains('Failed to notify') || output.contains('at org.gradle')) @@ -283,6 +271,27 @@ Future main() async { throw failure( 'Gradle output should contain a readable error message', result); + + section('flutter build apk on build script with error'); + await project.introduceError(); + result = await inDirectory(project.rootPath, () { + return executeFlutter('build', options: [ + 'apk', + '--release', + ]); + }); + if (result.exitCode == 0) + throw failure( + 'flutter build apk should fail when Gradle does', result); + output = '${result.stdout}\n${result.stderr}'; + if (!output.contains('Build failed')) + throw failure( + 'flutter build apk output should contain a readable Gradle error message', + result); + if (hasMultipleOccurrences(output, 'Build failed')) + throw failure( + 'flutter build apk should not invoke Gradle repeatedly on error', + result); }); await runProjectTest((FlutterProject project) async { @@ -302,45 +311,6 @@ Future main() async { throw failure(output, result); }); - await runProjectTest((FlutterProject project) async { - section('flutter build apk on build script with error'); - await project.introduceError(); - final ProcessResult result = await inDirectory(project.rootPath, () { - return executeFlutter('build', options: [ - 'apk', - '--release', - ]); - }); - if (result.exitCode == 0) - throw failure( - 'flutter build apk should fail when Gradle does', result); - final String output = '${result.stdout}\n${result.stderr}'; - if (!output.contains('Build failed')) - throw failure( - 'flutter build apk output should contain a readable Gradle error message', - result); - if (hasMultipleOccurrences(output, 'Build failed')) - throw failure( - 'flutter build apk should not invoke Gradle repeatedly on error', - result); - }); - - await runPluginProjectTest((FlutterPluginProject pluginProject) async { - section('gradlew assembleDebug on plugin example'); - await inDirectory(pluginProject.exampleAndroidPath, () { - return flutter( - 'build', - options: [ - 'apk', - '--debug', - ], - ); - }); - if (!File(pluginProject.debugApkPath).existsSync()) - throw TaskResult.failure( - 'Gradle did not produce an apk file at the expected place'); - }); - return TaskResult.success(null); } on TaskResult catch (taskResult) { return taskResult; diff --git a/dev/try_builders.json b/dev/try_builders.json index e6f80a1b25b..0c840ffa55a 100644 --- a/dev/try_builders.json +++ b/dev/try_builders.json @@ -493,7 +493,7 @@ "name": "Mac gradle_plugin_light_apk_test", "repo": "flutter", "task_name": "mac_gradle_plugin_light_apk_test", - "enabled": false, + "enabled": true, "run_if": ["dev/**", "bin/**"] }, {