diff --git a/fastlane/lib/fastlane/actions/spm.rb b/fastlane/lib/fastlane/actions/spm.rb index 414e7010deb..ee8df4a0194 100644 --- a/fastlane/lib/fastlane/actions/spm.rb +++ b/fastlane/lib/fastlane/actions/spm.rb @@ -12,6 +12,7 @@ def self.run(params) cmd << "--verbose" if params[:verbose] cmd << params[:command] if package_commands.include?(params[:command]) cmd << "--enable-code-coverage" if params[:enable_code_coverage] && (params[:command] == 'generate-xcodeproj' || params[:command] == 'test') + cmd << "--parallel" if params[:parallel] && params[:command] == 'test' if params[:xcconfig] cmd << "--xcconfig-overrides #{params[:xcconfig]}" end @@ -50,6 +51,11 @@ def self.available_options description: "Enables code coverage for the generated Xcode project when using the 'generate-xcodeproj' and the 'test' command", type: Boolean, optional: true), + FastlaneCore::ConfigItem.new(key: :parallel, + env_name: "FL_SPM_PARALLEL", + description: "Enables running tests in parallel when using the 'test' command", + type: Boolean, + default_value: false), FastlaneCore::ConfigItem.new(key: :build_path, env_name: "FL_SPM_BUILD_PATH", description: "Specify build/cache directory [default: ./.build]", @@ -116,6 +122,10 @@ def self.example_code 'spm( command: "generate-xcodeproj", xcconfig: "Package.xcconfig" + )', + 'spm( + command: "test", + parallel: true )' ] end diff --git a/fastlane/spec/actions_specs/spm_spec.rb b/fastlane/spec/actions_specs/spm_spec.rb index 498b600d2d2..af1d135d754 100644 --- a/fastlane/spec/actions_specs/spm_spec.rb +++ b/fastlane/spec/actions_specs/spm_spec.rb @@ -186,6 +186,48 @@ expect(result).to eq("swift test") end + + it "sets --parallel to true for test" do + result = Fastlane::FastFile.new.parse("lane :test do + spm( + command: 'test', + parallel: true + ) + end").runner.execute(:test) + + expect(result).to eq("swift test --parallel") + end + + it "sets --parellel to false for test" do + result = Fastlane::FastFile.new.parse("lane :test do + spm( + command: 'test', + parallel: false + ) + end").runner.execute(:test) + + expect(result).to eq("swift test") + end + + it "does not add --parellel by default" do + result = Fastlane::FastFile.new.parse("lane :test do + spm( + command: 'test' + ) + end").runner.execute(:test) + + expect(result).to eq("swift test") + end + + it "does not add --parellel for irrelevant commands" do + result = Fastlane::FastFile.new.parse("lane :test do + spm( + parallel: true + ) + end").runner.execute(:test) + + expect(result).to eq("swift build") + end end context "when command is package related" do