Skip to content

Commit

Permalink
[action][spm] add --very-verbose option (#21128)
Browse files Browse the repository at this point in the history
* add --very-verbose option to spm action

* delete short option

* merge master of upstream

* adds unit tests for --very-verbose option
  • Loading branch information
att55 authored Apr 13, 2024
1 parent 3060e06 commit 8699120
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fastlane/lib/fastlane/actions/spm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def self.run(params)
cmd << "--configuration #{params[:configuration]}" if params[:configuration]
cmd << "--disable-sandbox" if params[:disable_sandbox]
cmd << "--verbose" if params[:verbose]
cmd << "--very-verbose" if params[:very_verbose]
if params[:simulator]
simulator_platform = simulator_platform(simulator: params[:simulator], simulator_arch: params[:simulator_arch])
simulator_sdk = simulator_sdk(simulator: params[:simulator])
Expand Down Expand Up @@ -118,6 +119,12 @@ def self.available_options
description: "Increase verbosity of informational output",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :very_verbose,
short_option: "-V",
env_name: "FL_SPM_VERY_VERBOSE",
description: "Increase verbosity to include debug output",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :simulator,
env_name: "FL_SPM_SIMULATOR",
description: "Specifies the simulator to pass for Swift Compiler (one of: #{valid_simulators.join(', ')})",
Expand Down
51 changes: 51 additions & 0 deletions fastlane/spec/actions_specs/spm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@
expect(result).to eq("swift build")
end

it "adds very_verbose flag to command if very_verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(very_verbose: true)
end").runner.execute(:test)

expect(result).to eq("swift build --very-verbose")
end

it "doesn't add a very_verbose flag to command if very_verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(very_verbose: false)
end").runner.execute(:test)

expect(result).to eq("swift build")
end

it "adds build-path flag to command if build_path is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(build_path: 'foobar')
Expand Down Expand Up @@ -255,6 +271,28 @@
expect(result).to eq("swift package #{command}")
end

it "adds very_verbose flag to package command if very_verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
very_verbose: true
)
end").runner.execute(:test)

expect(result).to eq("swift package --very-verbose #{command}")
end

it "doesn't add a very_verbose flag to package command if very_verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
very_verbose: false
)
end").runner.execute(:test)

expect(result).to eq("swift package #{command}")
end

it "adds build-path flag to package command if package_path is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
Expand Down Expand Up @@ -380,6 +418,19 @@

expect(result).to eq("set -o pipefail && swift package --verbose generate-xcodeproj --xcconfig-overrides Package.xcconfig 2>&1 | xcpretty --simple")
end

it "adds --very-verbose and xcpretty options correctly as well" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
xcconfig: 'Package.xcconfig',
very_verbose: true,
xcpretty_output: 'simple'
)
end").runner.execute(:test)

expect(result).to eq("set -o pipefail && swift package --very-verbose generate-xcodeproj --xcconfig-overrides Package.xcconfig 2>&1 | xcpretty --simple")
end
end

context "when simulator is specified" do
Expand Down

0 comments on commit 8699120

Please sign in to comment.