Add CI steps to test iOS and macOS plugins with both CocoaPods and Swift Package Manager (#6557)

Tests new Swift Package Manager feature added in https://github.com/flutter/flutter/pull/146256.

Fixes https://github.com/flutter/flutter/issues/146901.
This commit is contained in:
Victoria Ashworth
2024-04-24 16:29:04 -05:00
committed by GitHub
parent 2925db2792
commit 1292dc30d8
4 changed files with 198 additions and 2 deletions

View File

@ -164,6 +164,98 @@ void main() {
]));
});
test('building for iOS with Swift Package Manager on master channel',
() async {
mockPlatform.isMacOS = true;
mockPlatform.environment['CHANNEL'] = 'master';
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformIOS: const PlatformDetails(PlatformSupport.inline),
});
final Directory pluginExampleDirectory = getExampleDir(plugin);
final List<String> output = await runCapturingPrint(runner, <String>[
'build-examples',
'--ios',
'--enable-experiment=exp1',
'--swift-package-manager',
]);
expect(
output,
containsAllInOrder(<String>[
'\nBUILDING plugin/example for iOS',
]),
);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['config', '--enable-swift-package-manager'],
null,
),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'build',
'ios',
'--no-codesign',
'--enable-experiment=exp1'
],
pluginExampleDirectory.path,
),
]),
);
});
test(
'building for iOS with Swift Package Manager on stable channel does not enable SPM',
() async {
mockPlatform.isMacOS = true;
mockPlatform.environment['CHANNEL'] = 'stable';
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformIOS: const PlatformDetails(PlatformSupport.inline),
});
final Directory pluginExampleDirectory = getExampleDir(plugin);
final List<String> output = await runCapturingPrint(runner, <String>[
'build-examples',
'--ios',
'--enable-experiment=exp1',
'--swift-package-manager',
]);
expect(
output,
containsAllInOrder(<String>[
'\nBUILDING plugin/example for iOS',
]),
);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'build',
'ios',
'--no-codesign',
'--enable-experiment=exp1'
],
pluginExampleDirectory.path,
),
]),
);
});
test(
'building for Linux when plugin is not set up for Linux results in no-op',
() async {
@ -261,6 +353,86 @@ void main() {
]));
});
test('building for macOS with Swift Package Manager on master channel',
() async {
mockPlatform.isMacOS = true;
mockPlatform.environment['CHANNEL'] = 'master';
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformMacOS: const PlatformDetails(PlatformSupport.inline),
});
final Directory pluginExampleDirectory = getExampleDir(plugin);
final List<String> output = await runCapturingPrint(runner,
<String>['build-examples', '--macos', '--swift-package-manager']);
expect(
output,
containsAllInOrder(<String>[
'\nBUILDING plugin/example for macOS',
]),
);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['config', '--enable-swift-package-manager'],
null,
),
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'build',
'macos',
],
pluginExampleDirectory.path,
),
]),
);
});
test(
'building for macOS with Swift Package Manager on stable channel does not enable SPM',
() async {
mockPlatform.isMacOS = true;
mockPlatform.environment['CHANNEL'] = 'stable';
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformMacOS: const PlatformDetails(PlatformSupport.inline),
});
final Directory pluginExampleDirectory = getExampleDir(plugin);
final List<String> output = await runCapturingPrint(runner,
<String>['build-examples', '--macos', '--swift-package-manager']);
expect(
output,
containsAllInOrder(<String>[
'\nBUILDING plugin/example for macOS',
]),
);
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>[
'build',
'macos',
],
pluginExampleDirectory.path,
),
]),
);
});
test('building for web with no implementation results in no-op', () async {
createFakePlugin('plugin', packagesDir);