Unverified Commit 21a53269 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Split gradle_plugin_test.dart (#34282)

Fixes timeout when running gradle_plugin_test
parent 82479636
......@@ -769,7 +769,9 @@ Future<void> _integrationTestsAndroidSdk() async {
// TODO(dnfield): gradlew is crashing on the cirrus image and it's not clear why.
if (!Platform.isWindows) {
await _runDevicelabTest('gradle_plugin_test', env: env);
await _runDevicelabTest('gradle_plugin_light_apk_test', env: env);
await _runDevicelabTest('gradle_plugin_fat_apk_test', env: env);
await _runDevicelabTest('gradle_plugin_bundle_test', env: env);
await _runDevicelabTest('module_test', env: env);
}
// note: this also covers plugin_test_win as long as Windows has an Android SDK available.
......
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<void> main() async {
await task(() async {
try {
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('App bundle content for task bundleRelease without explicit target platform');
await pluginProject.runGradleTask('bundleRelease');
if (!pluginProject.hasReleaseBundle)
throw TaskResult.failure(
'Gradle did not produce a release aab file at: ${pluginProject.releaseBundlePath}');
final Iterable<String> bundleFiles = await pluginProject.getFilesInAppBundle(pluginProject.releaseBundlePath);
checkItContains<String>(<String>[
'base/manifest/AndroidManifest.xml',
'base/dex/classes.dex',
'base/lib/arm64-v8a/libapp.so',
'base/lib/arm64-v8a/libflutter.so',
'base/lib/armeabi-v7a/libapp.so',
'base/lib/armeabi-v7a/libflutter.so',
], bundleFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('App bundle content for task bundleRelease with target platform = android-arm');
await pluginProject.runGradleTask('bundleRelease',
options: <String>['-Ptarget-platform=android-arm']);
if (!pluginProject.hasReleaseBundle)
throw TaskResult.failure(
'Gradle did not produce a release aab file at: ${pluginProject.releaseBundlePath}');
final Iterable<String> bundleFiles = await pluginProject.getFilesInAppBundle(pluginProject.releaseBundlePath);
checkItContains<String>(<String>[
'base/manifest/AndroidManifest.xml',
'base/dex/classes.dex',
'base/lib/armeabi-v7a/libapp.so',
'base/lib/armeabi-v7a/libflutter.so',
], bundleFiles);
checkItDoesNotContain<String>(<String>[
'base/lib/arm64-v8a/libapp.so',
'base/lib/arm64-v8a/libflutter.so',
], bundleFiles);
});
return TaskResult.success(null);
} on TaskResult catch (taskResult) {
return taskResult;
} catch (e) {
return TaskResult.failure(e.toString());
}
});
}
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<void> main() async {
await task(() async {
try {
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleDebug without explicit target platform');
await pluginProject.runGradleTask('assembleDebug');
if (!pluginProject.hasDebugApk)
throw TaskResult.failure(
'Gradle did not produce a debug apk file at: ${pluginProject.debugApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.debugApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
'lib/arm64-v8a/libflutter.so',
'lib/armeabi-v7a/libflutter.so',
// Debug mode intentionally includes `x86` and `x86_64`.
'lib/x86/libflutter.so',
'lib/x86_64/libflutter.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'lib/arm64-v8a/libapp.so',
'lib/armeabi-v7a/libapp.so',
'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 pluginProject.runGradleTask('assembleRelease');
if (!pluginProject.hasReleaseApk)
throw TaskResult.failure(
'Gradle did not produce a release apk file at: ${pluginProject.releaseApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.releaseApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so',
'lib/armeabi-v7a/libflutter.so',
'lib/armeabi-v7a/libapp.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with target platform = android-arm, android-arm64');
await pluginProject.runGradleTask('assembleRelease',
options: <String>['-Ptarget-platform=android-arm,android-arm64']);
if (!pluginProject.hasReleaseApk)
throw TaskResult.failure(
'Gradle did not produce a release apk at: ${pluginProject.releaseApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.releaseApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/armeabi-v7a/libflutter.so',
'lib/armeabi-v7a/libapp.so',
'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with '
'target platform = android-arm, android-arm64 and split per ABI');
await pluginProject.runGradleTask('assembleRelease',
options: <String>['-Ptarget-platform=android-arm,android-arm64', '-Psplit-per-abi=true']);
if (!pluginProject.hasReleaseArmApk)
throw TaskResult.failure(
'Gradle did not produce a release apk at: ${pluginProject.releaseArmApkPath}');
final Iterable<String> armApkFiles = await pluginProject.getFilesInApk(pluginProject.releaseArmApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/armeabi-v7a/libflutter.so',
'lib/armeabi-v7a/libapp.so',
], armApkFiles);
checkItDoesNotContain<String>(<String>[
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], armApkFiles);
if (!pluginProject.hasReleaseArm64Apk)
throw TaskResult.failure(
'Gradle did not produce a release apk at: ${pluginProject.releaseArm64ApkPath}');
final Iterable<String> arm64ApkFiles = await pluginProject.getFilesInApk(pluginProject.releaseArm64ApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so',
], arm64ApkFiles);
checkItDoesNotContain<String>(<String>[
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], arm64ApkFiles);
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleRelease');
await project.runGradleTask('assembleRelease');
// When the platform-target isn't specified, we generate the snapshots
// for arm and arm64.
final List<String> targetPlatforms = <String>[
'android-arm',
'android-arm64'
];
for (final String targetPlatform in targetPlatforms) {
final String androidArmSnapshotPath = path.join(
project.rootPath,
'build',
'app',
'intermediates',
'flutter',
'release',
targetPlatform);
final String sharedLibrary = path.join(androidArmSnapshotPath, 'app.so');
if (!File(sharedLibrary).existsSync()) {
throw TaskResult.failure('Shared library doesn\'t exist');
}
}
});
return TaskResult.success(null);
} on TaskResult catch (taskResult) {
return taskResult;
} catch (e) {
return TaskResult.failure(e.toString());
}
});
}
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<void> main() async {
await task(() async {
try {
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleDebug with target platform = android-arm');
await pluginProject.runGradleTask('assembleDebug',
options: <String>['-Ptarget-platform=android-arm']);
if (!pluginProject.hasDebugApk)
throw TaskResult.failure(
'Gradle did not produce a debug apk file at: ${pluginProject.debugApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.debugApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
'lib/armeabi-v7a/libflutter.so',
// Debug mode intentionally includes `x86` and `x86_64`.
'lib/x86/libflutter.so',
'lib/x86_64/libflutter.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'lib/armeabi-v7a/libapp.so',
'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 pluginProject.runGradleTask('assembleRelease',
options: <String>['-Ptarget-platform=android-arm']);
if (!pluginProject.hasReleaseApk)
throw TaskResult.failure(
'Gradle did not produce a release apk file at: ${pluginProject.releaseApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.releaseApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/armeabi-v7a/libflutter.so',
'lib/armeabi-v7a/libapp.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so',
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], apkFiles);
});
await runPluginProjectTest((FlutterPluginProject pluginProject) async {
section('APK content for task assembleRelease with target platform = android-arm64');
await pluginProject.runGradleTask('assembleRelease',
options: <String>['-Ptarget-platform=android-arm64']);
if (!pluginProject.hasReleaseApk)
throw TaskResult.failure(
'Gradle did not produce a release apk file at: ${pluginProject.releaseApkPath}');
final Iterable<String> apkFiles = await pluginProject.getFilesInApk(pluginProject.releaseApkPath);
checkItContains<String>(<String>[
'AndroidManifest.xml',
'classes.dex',
'lib/arm64-v8a/libflutter.so',
'lib/arm64-v8a/libapp.so',
], apkFiles);
checkItDoesNotContain<String>(<String>[
'lib/armeabi-v7a/libflutter.so',
'lib/armeabi-v7a/libapp.so',
'assets/flutter_assets/isolate_snapshot_data',
'assets/flutter_assets/kernel_blob.bin',
'assets/flutter_assets/vm_snapshot_data',
], apkFiles);
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleDebug');
await project.runGradleTask('assembleDebug');
final String errorMessage = validateSnapshotDependency(project, 'build/app.dill');
if (errorMessage != null) {
throw TaskResult.failure(errorMessage);
}
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleProfile');
await project.runGradleTask('assembleProfile');
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleLocal (custom debug build)');
await project.addCustomBuildType('local', initWith: 'debug');
await project.runGradleTask('assembleLocal');
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleBeta (custom release build)');
await project.addCustomBuildType('beta', initWith: 'release');
await project.runGradleTask('assembleBeta');
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleFreeDebug (product flavor)');
await project.addProductFlavor('free');
await project.runGradleTask('assembleFreeDebug');
});
await runProjectTest((FlutterProject project) async {
section('gradlew on build script with error');
await project.introduceError();
final ProcessResult result =
await project.resultOfGradleTask('assembleRelease');
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('GradleException') ||
output.contains('Failed to notify') ||
output.contains('at org.gradle'))
throw failure(
'Gradle output should not contain stacktrace', result);
if (!output.contains('Build failed') || !output.contains('builTypes'))
throw failure(
'Gradle output should contain a readable error message',
result);
});
await runProjectTest((FlutterProject project) async {
section('flutter build apk on build script with error');
await project.introduceError();
final ProcessResult result = await project.resultOfFlutterCommand('build', <String>['apk']);
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') || !output.contains('builTypes'))
throw failure(
'flutter build apk output should contain a readable Gradle error message',
result);
if (hasMultipleOccurrences(output, 'builTypes'))
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 pluginProject.runGradleTask('assembleDebug');
if (!pluginProject.hasDebugApk)
throw TaskResult.failure(
'Gradle did not produce an apk file at the expected place');
});
return TaskResult.success(null);
} on TaskResult catch (taskResult) {
return taskResult;
} catch (e) {
return TaskResult.failure(e.toString());
}
});
}
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