mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Reduce number of project creates in gradle_plugin_*_apk_tests (#80171)
This commit is contained in:
parent
436ca01e14
commit
2d688804f6
@ -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>[
|
||||
...flutterAssets,
|
||||
@ -44,9 +44,7 @@ Future<void> 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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -73,9 +71,7 @@ Future<void> main() async {
|
||||
], apkFiles);
|
||||
|
||||
checkCollectionDoesNotContain<String>(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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -101,9 +97,7 @@ Future<void> main() async {
|
||||
], apkFiles);
|
||||
|
||||
checkCollectionDoesNotContain<String>(debugAssets, apkFiles);
|
||||
});
|
||||
|
||||
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
|
||||
section('APK content for task assembleRelease with '
|
||||
'target platform = android-arm, android-arm64 and split per ABI');
|
||||
|
||||
|
||||
@ -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>[
|
||||
...flutterAssets,
|
||||
@ -45,9 +45,7 @@ Future<void> 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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.debugApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -77,9 +75,7 @@ Future<void> 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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.debugApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.debugApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -110,9 +106,7 @@ Future<void> 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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -140,9 +134,7 @@ Future<void> 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<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final Iterable<String> apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
apkFiles = await getFilesInApk(pluginProject.releaseApkPath);
|
||||
|
||||
checkCollectionContains<String>(<String>[
|
||||
...flutterAssets,
|
||||
@ -187,9 +179,7 @@ Future<void> 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<void> 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<void> 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: <String>[
|
||||
'apk',
|
||||
'--release',
|
||||
@ -273,7 +261,7 @@ Future<void> 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<void> 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: <String>[
|
||||
'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<void> 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: <String>[
|
||||
'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: <String>[
|
||||
'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;
|
||||
|
||||
@ -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/**"]
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user