Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
don't build with Swift Package Manager on stable
  • Loading branch information
vashworth committed Apr 24, 2024
commit ce01604b0c4e47b9919f93835e71767242a58f80
2 changes: 1 addition & 1 deletion .ci/targets/ios_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tasks:
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps", "--ios", "--supporting-target-platforms-only"]
infra_step: true
- name: build examples with Swift Package Manager integration
- name: build examples
script: .ci/scripts/tool_runner.sh
args: ["build-examples", "--ios", "--swift-package-manager"]
- name: xcode analyze
Expand Down
2 changes: 1 addition & 1 deletion .ci/targets/macos_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tasks:
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps", "--macos", "--supporting-target-platforms-only"]
infra_step: true
- name: build examples with Swift Package Manager integration
- name: build examples
script: .ci/scripts/tool_runner.sh
args: ["build-examples", "--macos", "--swift-package-manager"]
- name: xcode analyze
Expand Down
5 changes: 4 additions & 1 deletion script/tool/lib/src/build_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ class BuildExamplesCommand extends PackageLoopingCommand {
throw ToolExit(_exitNoPlatformFlags);
}

if (usingSwiftPackageManager) {
// TODO(vashworth): Enable on stable once Swift Package Manager feature is
// available on stable.
if (usingSwiftPackageManager &&
platform.environment['CHANNEL'] != 'stable') {
await processRunner.runAndStream(
flutterCommand,
<String>['config', '--enable-swift-package-manager'],
Expand Down
92 changes: 90 additions & 2 deletions script/tool/test/build_examples_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ void main() {
]));
});

test('building for iOS with Swift Package Manager', () async {
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),
Expand Down Expand Up @@ -209,6 +212,50 @@ void main() {
);
});

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 {
Expand Down Expand Up @@ -306,8 +353,11 @@ void main() {
]));
});

test('building for macOS with Swift Package Manager', () async {
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),
Expand Down Expand Up @@ -345,6 +395,44 @@ void main() {
);
});

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);

Expand Down