Unverified Commit 2d688804 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Reduce number of project creates in gradle_plugin_*_apk_tests (#80171)

parent 436ca01e
...@@ -25,7 +25,7 @@ Future<void> main() async { ...@@ -25,7 +25,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath); Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -44,9 +44,7 @@ Future<void> main() async { ...@@ -44,9 +44,7 @@ Future<void> main() async {
'lib/x86/libapp.so', 'lib/x86/libapp.so',
'lib/x86_64/libapp.so', 'lib/x86_64/libapp.so',
], apkFiles); ], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease without explicit target platform'); section('APK content for task assembleRelease without explicit target platform');
await inDirectory(pluginProject.exampleAndroidPath, () { await inDirectory(pluginProject.exampleAndroidPath, () {
...@@ -59,7 +57,7 @@ Future<void> main() async { ...@@ -59,7 +57,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath); apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -73,9 +71,7 @@ Future<void> main() async { ...@@ -73,9 +71,7 @@ Future<void> main() async {
], apkFiles); ], apkFiles);
checkCollectionDoesNotContain<String>(debugAssets, apkFiles); checkCollectionDoesNotContain<String>(debugAssets, apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with target platform = android-arm, android-arm64'); section('APK content for task assembleRelease with target platform = android-arm, android-arm64');
await inDirectory(pluginProject.exampleAndroidPath, () { await inDirectory(pluginProject.exampleAndroidPath, () {
...@@ -89,7 +85,7 @@ Future<void> main() async { ...@@ -89,7 +85,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath); apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -101,9 +97,7 @@ Future<void> main() async { ...@@ -101,9 +97,7 @@ Future<void> main() async {
], apkFiles); ], apkFiles);
checkCollectionDoesNotContain<String>(debugAssets, apkFiles); checkCollectionDoesNotContain<String>(debugAssets, apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with ' section('APK content for task assembleRelease with '
'target platform = android-arm, android-arm64 and split per ABI'); 'target platform = android-arm, android-arm64 and split per ABI');
......
...@@ -27,7 +27,7 @@ Future<void> main() async { ...@@ -27,7 +27,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath); Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -45,9 +45,7 @@ Future<void> main() async { ...@@ -45,9 +45,7 @@ Future<void> main() async {
'lib/x86/libapp.so', 'lib/x86/libapp.so',
'lib/x86_64/libapp.so', 'lib/x86_64/libapp.so',
], apkFiles); ], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleDebug with target platform = android-x86'); section('APK content for task assembleDebug with target platform = android-x86');
// This is used by `flutter run` // This is used by `flutter run`
await inDirectory(pluginProject.exampleAndroidPath, () { await inDirectory(pluginProject.exampleAndroidPath, () {
...@@ -61,7 +59,7 @@ Future<void> main() async { ...@@ -61,7 +59,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath); apkFiles = await getFilesInApk(pluginProject.debugApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -77,9 +75,7 @@ Future<void> main() async { ...@@ -77,9 +75,7 @@ Future<void> main() async {
'lib/x86/libapp.so', 'lib/x86/libapp.so',
'lib/x86_64/libapp.so', 'lib/x86_64/libapp.so',
], apkFiles); ], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleDebug with target platform = android-x64'); section('APK content for task assembleDebug with target platform = android-x64');
// This is used by `flutter run` // This is used by `flutter run`
...@@ -94,7 +90,7 @@ Future<void> main() async { ...@@ -94,7 +90,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath); apkFiles = await getFilesInApk(pluginProject.debugApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -110,9 +106,7 @@ Future<void> main() async { ...@@ -110,9 +106,7 @@ Future<void> main() async {
'lib/x86/libapp.so', 'lib/x86/libapp.so',
'lib/x86_64/libapp.so', 'lib/x86_64/libapp.so',
], apkFiles); ], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with target platform = android-arm'); section('APK content for task assembleRelease with target platform = android-arm');
await inDirectory(pluginProject.exampleAndroidPath, () { await inDirectory(pluginProject.exampleAndroidPath, () {
...@@ -126,7 +120,7 @@ Future<void> main() async { ...@@ -126,7 +120,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath); apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -140,9 +134,7 @@ Future<void> main() async { ...@@ -140,9 +134,7 @@ Future<void> main() async {
'lib/arm64-v8a/libflutter.so', 'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so', 'lib/arm64-v8a/libapp.so',
], apkFiles); ], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with target platform = android-arm64'); section('APK content for task assembleRelease with target platform = android-arm64');
await inDirectory(pluginProject.exampleAndroidPath, () { await inDirectory(pluginProject.exampleAndroidPath, () {
...@@ -156,7 +148,7 @@ Future<void> main() async { ...@@ -156,7 +148,7 @@ Future<void> main() async {
); );
}); });
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath); apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
checkCollectionContains<String>(<String>[ checkCollectionContains<String>(<String>[
...flutterAssets, ...flutterAssets,
...@@ -187,9 +179,7 @@ Future<void> main() async { ...@@ -187,9 +179,7 @@ Future<void> main() async {
if (errorMessage != null) { if (errorMessage != null) {
throw TaskResult.failure(errorMessage); throw TaskResult.failure(errorMessage);
} }
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleProfile'); section('gradlew assembleProfile');
await inDirectory(project.rootPath, () { await inDirectory(project.rootPath, () {
return flutter( return flutter(
...@@ -200,9 +190,7 @@ Future<void> main() async { ...@@ -200,9 +190,7 @@ Future<void> main() async {
], ],
); );
}); });
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleLocal (custom debug build)'); section('gradlew assembleLocal (custom debug build)');
await project.addCustomBuildType('local', initWith: 'debug'); await project.addCustomBuildType('local', initWith: 'debug');
await project.runGradleTask('assembleLocal'); await project.runGradleTask('assembleLocal');
...@@ -263,7 +251,7 @@ Future<void> main() async { ...@@ -263,7 +251,7 @@ Future<void> main() async {
await runProjectTest((FlutterProject project) async { await runProjectTest((FlutterProject project) async {
section('gradlew on build script with error'); section('gradlew on build script with error');
await project.introduceError(); await project.introduceError();
final ProcessResult result = await inDirectory(project.rootPath, () { ProcessResult result = await inDirectory(project.rootPath, () {
return executeFlutter('build', options: <String>[ return executeFlutter('build', options: <String>[
'apk', 'apk',
'--release', '--release',
...@@ -273,7 +261,7 @@ Future<void> main() async { ...@@ -273,7 +261,7 @@ Future<void> main() async {
if (result.exitCode == 0) if (result.exitCode == 0)
throw failure( throw failure(
'Gradle did not exit with error as expected', result); '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') || if (output.contains('GradleException') ||
output.contains('Failed to notify') || output.contains('Failed to notify') ||
output.contains('at org.gradle')) output.contains('at org.gradle'))
...@@ -283,29 +271,10 @@ Future<void> main() async { ...@@ -283,29 +271,10 @@ Future<void> main() async {
throw failure( throw failure(
'Gradle output should contain a readable error message', 'Gradle output should contain a readable error message',
result); result);
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleDebug forwards stderr');
await project.introducePubspecError();
final ProcessResult result = await inDirectory(project.rootPath, () {
return executeFlutter('build', options: <String>[
'apk',
'--release',
]);
});
if (result.exitCode == 0)
throw failure(
'Gradle did not exit with error as expected', result);
final String output = '${result.stdout}\n${result.stderr}';
if (!output.contains('No file or variants found for asset: lib/gallery/example_code.dart.'))
throw failure(output, result);
});
await runProjectTest((FlutterProject project) async {
section('flutter build apk on build script with error'); section('flutter build apk on build script with error');
await project.introduceError(); await project.introduceError();
final ProcessResult result = await inDirectory(project.rootPath, () { result = await inDirectory(project.rootPath, () {
return executeFlutter('build', options: <String>[ return executeFlutter('build', options: <String>[
'apk', 'apk',
'--release', '--release',
...@@ -314,7 +283,7 @@ Future<void> main() async { ...@@ -314,7 +283,7 @@ Future<void> main() async {
if (result.exitCode == 0) if (result.exitCode == 0)
throw failure( throw failure(
'flutter build apk should fail when Gradle does', result); 'flutter build apk should fail when Gradle does', result);
final String output = '${result.stdout}\n${result.stderr}'; output = '${result.stdout}\n${result.stderr}';
if (!output.contains('Build failed')) if (!output.contains('Build failed'))
throw failure( throw failure(
'flutter build apk output should contain a readable Gradle error message', 'flutter build apk output should contain a readable Gradle error message',
...@@ -325,20 +294,21 @@ Future<void> main() async { ...@@ -325,20 +294,21 @@ Future<void> main() async {
result); result);
}); });
await runPluginProjectTest((FlutterPluginProject pluginProject) async { await runProjectTest((FlutterProject project) async {
section('gradlew assembleDebug on plugin example'); section('gradlew assembleDebug forwards stderr');
await inDirectory(pluginProject.exampleAndroidPath, () { await project.introducePubspecError();
return flutter( final ProcessResult result = await inDirectory(project.rootPath, () {
'build', return executeFlutter('build', options: <String>[
options: <String>[ 'apk',
'apk', '--release',
'--debug', ]);
],
);
}); });
if (!File(pluginProject.debugApkPath).existsSync()) if (result.exitCode == 0)
throw TaskResult.failure( throw failure(
'Gradle did not produce an apk file at the expected place'); 'Gradle did not exit with error as expected', result);
final String output = '${result.stdout}\n${result.stderr}';
if (!output.contains('No file or variants found for asset: lib/gallery/example_code.dart.'))
throw failure(output, result);
}); });
return TaskResult.success(null); return TaskResult.success(null);
......
...@@ -493,7 +493,7 @@ ...@@ -493,7 +493,7 @@
"name": "Mac gradle_plugin_light_apk_test", "name": "Mac gradle_plugin_light_apk_test",
"repo": "flutter", "repo": "flutter",
"task_name": "mac_gradle_plugin_light_apk_test", "task_name": "mac_gradle_plugin_light_apk_test",
"enabled": false, "enabled": true,
"run_if": ["dev/**", "bin/**"] "run_if": ["dev/**", "bin/**"]
}, },
{ {
......
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