Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action][spm] add simulator flag for swift compiler #21707

Merged
merged 17 commits into from Dec 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 1 addition & 14 deletions fastlane/spec/actions_specs/spm_spec.rb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it looks like the macOS simulator command wasn't working (? can't really tell for sure ATM), is there any way we can add a unit test that makes sure not only the output command is the expected string, but that the command actually works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to find a way to actually test the code in unit tests. I was thinking of using open3 to catch the result of executing command, but then testing the swift build command needs an actual SPM. So wasn't making sense to me. Any suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, if we wanted, we could create a sample SPM just for testing purposes. But, on a second thought, I think we actually might not need this, as long as we test it manually and make sure it works with all configurations, this should be fine. The reason is that we'd be validating whether "swift build" works, and that's not really the intent of what fastlane's unit tests should be :)

So this is good as is 🙏 thank you!

Expand Up @@ -360,20 +360,7 @@
simulator: 'invalid_simulator'
)
end").runner.execute(:test)
end.to raise_error("Invalid simulator syntax. Please use 'iphonesimulator', 'ipadsimulator', or 'macossimulator'.")
end
end

context "when simulator is specified for non-package commands" do
it "raises an error" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'clean',
simulator: 'iphonesimulator'
)
end").runner.execute(:test)
end.to raise_error("Simulator is only applicable to package-related commands.")
end.to raise_error("Invalid simulator syntax. Please use 'iphonesimulator', or 'macossimulator'.")
gharary marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
Expand Down