Skip to content

Commit c5f8b9b

Browse files
Remove manually-combined darwin/ plugin tests (flutter#192890)
To ensure that `sharedDarwinSource` plugins worked, we had tests that created standard iOS/macOS plugins and then attempted to manually modify them to use `darwin/` and `sharedDarwinSource: true`. However, we now have template options to directly create such plugins, and we are already running tests with them, so we don't need to run the duplicate tests that construct them manually. This both reduces infra time, and avoids the need to maintain project manipulation code that knows the exact source of the template files (which makes updating the code in the templates more difficult). Helps unblock flutter#63284 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 340297b commit c5f8b9b

2 files changed

Lines changed: 0 additions & 95 deletions

File tree

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import 'package:flutter_devicelab/tasks/plugin_tests.dart';
88
Future<void> main() async {
99
await task(
1010
combine(<TaskFunction>[
11-
// Test that shared darwin directories are supported on iOS.
12-
PluginTest('ios', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
13-
// Test that shared darwin directories are supported on macOS.
14-
PluginTest('macos', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,
1511
// Test that iOS plugins support the darwin platform.
1612
PluginTest('ios', <String>['--platforms=darwin']).call,
1713
// Test that macOS plugins support the darwin platform.

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

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class PluginTest {
3636
this.pluginCreateEnvironment,
3737
this.appCreateEnvironment,
3838
this.dartOnlyPlugin = false,
39-
this.sharedDarwinSource = false,
4039
this.template = 'plugin',
4140
this.cocoapodsTransitiveFlutterDependency = false,
4241
});
@@ -46,7 +45,6 @@ class PluginTest {
4645
final Map<String, String>? pluginCreateEnvironment;
4746
final Map<String, String>? appCreateEnvironment;
4847
final bool dartOnlyPlugin;
49-
final bool sharedDarwinSource;
5048
final String template;
5149
final bool cocoapodsTransitiveFlutterDependency;
5250

@@ -69,9 +67,6 @@ class PluginTest {
6967
if (dartOnlyPlugin) {
7068
await plugin.convertDefaultPluginToDartPlugin();
7169
}
72-
if (sharedDarwinSource) {
73-
await plugin.convertDefaultPluginToSharedDarwinPlugin();
74-
}
7570
section('Test plugin');
7671
if (runFlutterTest) {
7772
await plugin.runFlutterTest();
@@ -233,92 +228,6 @@ class $dartPluginClass {
233228
}
234229
}
235230

236-
/// Converts an iOS/macOS plugin created from the standard template to a shared
237-
/// darwin directory plugin.
238-
Future<void> convertDefaultPluginToSharedDarwinPlugin() async {
239-
// Convert the metadata.
240-
final File pubspec = pubspecFile;
241-
String pubspecContent = await pubspec.readAsString();
242-
const originalIOSKey = '\n ios:\n';
243-
const originalMacOSKey = '\n macos:\n';
244-
if (!pubspecContent.contains(originalIOSKey) || !pubspecContent.contains(originalMacOSKey)) {
245-
print(pubspecContent);
246-
throw TaskResult.failure('Missing expected darwin platform plugin keys');
247-
}
248-
pubspecContent = pubspecContent.replaceAll(
249-
originalIOSKey,
250-
'$originalIOSKey sharedDarwinSource: true\n',
251-
);
252-
pubspecContent = pubspecContent.replaceAll(
253-
originalMacOSKey,
254-
'$originalMacOSKey sharedDarwinSource: true\n',
255-
);
256-
await pubspec.writeAsString(pubspecContent, flush: true);
257-
258-
// Copy ios to darwin, and delete macos.
259-
final iosDir = Directory(path.join(rootPath, 'ios'));
260-
final darwinDir = Directory(path.join(rootPath, 'darwin'));
261-
recursiveCopy(iosDir, darwinDir);
262-
263-
await iosDir.delete(recursive: true);
264-
await Directory(path.join(rootPath, 'macos')).delete(recursive: true);
265-
266-
final podspec = File(path.join(darwinDir.path, '$name.podspec'));
267-
String podspecContent = await podspec.readAsString();
268-
if (!podspecContent.contains('s.platform =')) {
269-
print(podspecContent);
270-
throw TaskResult.failure('Missing expected podspec platform');
271-
}
272-
273-
// Remove "s.platform = :ios" to work on all platforms, including macOS.
274-
podspecContent = podspecContent.replaceFirst(RegExp(r'.*s\.platform.*'), '');
275-
podspecContent = podspecContent.replaceFirst(
276-
"s.dependency 'Flutter'",
277-
"s.ios.dependency 'Flutter'\ns.osx.dependency 'FlutterMacOS'",
278-
);
279-
280-
await podspec.writeAsString(podspecContent, flush: true);
281-
282-
// Make PlugintestPlugin.swift compile on iOS and macOS with target conditionals.
283-
// If SwiftPM is disabled, the file will be in `darwin/Classes/`.
284-
// Otherwise, the file will be in `darwin/<plugin>/Sources/<plugin>/`.
285-
final pluginClass = '${name[0].toUpperCase()}${name.substring(1)}Plugin';
286-
print('pluginClass: $pluginClass');
287-
var pluginRegister = File(path.join(darwinDir.path, 'Classes', '$pluginClass.swift'));
288-
if (!pluginRegister.existsSync()) {
289-
pluginRegister = File(path.join(darwinDir.path, name, 'Sources', name, '$pluginClass.swift'));
290-
}
291-
final pluginRegisterContent =
292-
'''
293-
#if os(macOS)
294-
import FlutterMacOS
295-
#elseif os(iOS)
296-
import Flutter
297-
#endif
298-
299-
public class $pluginClass: NSObject, FlutterPlugin {
300-
public static func register(with registrar: FlutterPluginRegistrar) {
301-
#if os(macOS)
302-
let channel = FlutterMethodChannel(name: "$name", binaryMessenger: registrar.messenger)
303-
#elseif os(iOS)
304-
let channel = FlutterMethodChannel(name: "$name", binaryMessenger: registrar.messenger())
305-
#endif
306-
let instance = $pluginClass()
307-
registrar.addMethodCallDelegate(instance, channel: channel)
308-
}
309-
310-
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
311-
#if os(macOS)
312-
result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
313-
#elseif os(iOS)
314-
result("iOS " + UIDevice.current.systemVersion)
315-
#endif
316-
}
317-
}
318-
''';
319-
await pluginRegister.writeAsString(pluginRegisterContent, flush: true);
320-
}
321-
322231
Future<void> runFlutterTest() async {
323232
await inDirectory(Directory(rootPath), () async {
324233
await flutter('test');

0 commit comments

Comments
 (0)