Skip to content

Commit 638302c

Browse files
committed
Skip redundant work in plugin_test_ios
The CocoaPods-transitive-dependency variant creates and tests the same plugin as the first variant (unit tests, native tests, flutter run on a simulator) before getting to the app that differs. Add a testPlugin flag and turn it off there. runNativeTests did a full flutter build before xcodebuild test or gradlew testDebugUnitTest, both of which compile the app themselves. Only the project configuration is needed, so use --config-only on iOS, macOS, and Android. Linux and Windows run a test binary from the build directory and keep the full build. This also applies to plugin_test_darwin, plugin_test_macos, and plugin_test_android_*. Part of flutter#193513
1 parent 0ea8af4 commit 638302c

2 files changed

Lines changed: 36 additions & 18 deletions

File tree

‎dev/devicelab/bin/tasks/plugin_test_ios.dart‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ Future<void> main() async {
99
await task(
1010
combine(<TaskFunction>[
1111
PluginTest('ios', <String>['--platforms=ios']).call,
12-
// Test that app builds with Flutter as a transitive dependency.
13-
PluginTest('ios', <String>[
14-
'--platforms=ios',
15-
], cocoapodsTransitiveFlutterDependency: true).call,
12+
// Test that app builds with Flutter as a transitive dependency. The
13+
// plugin is the same as above.
14+
PluginTest(
15+
'ios',
16+
<String>['--platforms=ios'],
17+
cocoapodsTransitiveFlutterDependency: true,
18+
testPlugin: false,
19+
).call,
1620
// Test that Dart-only plugins are supported.
1721
PluginTest('ios', <String>['--platforms=ios'], dartOnlyPlugin: true).call,
1822
// Test that FFI plugins are supported.

‎dev/devicelab/lib/tasks/plugin_tests.dart‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class PluginTest {
3838
this.dartOnlyPlugin = false,
3939
this.template = 'plugin',
4040
this.cocoapodsTransitiveFlutterDependency = false,
41+
this.testPlugin = true,
4142
});
4243

4344
final String buildTarget;
@@ -48,6 +49,9 @@ class PluginTest {
4849
final String template;
4950
final bool cocoapodsTransitiveFlutterDependency;
5051

52+
/// Whether to test the plugin itself before building the app that uses it.
53+
final bool testPlugin;
54+
5155
Future<TaskResult> call() async {
5256
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_plugin_test.');
5357
// FFI plugins do not have support for `flutter test`.
@@ -67,18 +71,20 @@ class PluginTest {
6771
if (dartOnlyPlugin) {
6872
await plugin.convertDefaultPluginToDartPlugin();
6973
}
70-
section('Test plugin');
71-
if (runFlutterTest) {
72-
await plugin.runFlutterTest();
73-
if (!dartOnlyPlugin) {
74-
await plugin.example.runNativeTests(buildTarget);
75-
if (buildTarget == 'ios') {
76-
var runResult = false;
77-
await testWithNewIOSSimulator('TestPluginExample', (String deviceId) async {
78-
runResult = await plugin.example.runApp(options: <String>['-d', deviceId]);
79-
});
80-
if (!runResult) {
81-
return TaskResult.failure('flutter run either failed or had an engine error.');
74+
if (testPlugin) {
75+
section('Test plugin');
76+
if (runFlutterTest) {
77+
await plugin.runFlutterTest();
78+
if (!dartOnlyPlugin) {
79+
await plugin.example.runNativeTests(buildTarget);
80+
if (buildTarget == 'ios') {
81+
var runResult = false;
82+
await testWithNewIOSSimulator('TestPluginExample', (String deviceId) async {
83+
runResult = await plugin.example.runApp(options: <String>['-d', deviceId]);
84+
});
85+
if (!runResult) {
86+
return TaskResult.failure('flutter run either failed or had an engine error.');
87+
}
8288
}
8389
}
8490
}
@@ -236,8 +242,16 @@ class $dartPluginClass {
236242

237243
Future<void> runNativeTests(String buildTarget) async {
238244
// Native unit tests rely on building the app first to generate necessary
239-
// build files.
240-
await build(buildTarget, validateNativeBuildProject: false, buildMode: 'debug');
245+
// build files. xcodebuild and Gradle compile the app themselves, so only
246+
// generate the project configuration. Linux and Windows run a test binary
247+
// from the build directory and need the full build.
248+
final bool needsFullBuild = buildTarget == 'linux' || buildTarget == 'windows';
249+
await build(
250+
buildTarget,
251+
validateNativeBuildProject: false,
252+
configOnly: !needsFullBuild,
253+
buildMode: 'debug',
254+
);
241255

242256
switch (buildTarget) {
243257
case 'apk':

0 commit comments

Comments
 (0)