Skip to content

Commit

Permalink
Duplicate swiftlint custom executable parameter, so it doesn't get co…
Browse files Browse the repository at this point in the history
…rrupted (#9535)

* Duplicate the executable reference, so it doesn't get corrupted

* Formatting inprovements from peer review
  • Loading branch information
nap-sam-dean authored and mpirri committed Jun 23, 2017
1 parent ed4108a commit b6e1aa2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastlane/lib/fastlane/actions/swiftlint.rb
Expand Up @@ -11,7 +11,7 @@ def self.run(params)
UI.user_error!("Your version of swiftlint (#{version}) does not support autocorrect mode.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`")
end

command = params[:executable].nil? ? "swiftlint" : params[:executable]
command = (params[:executable] || "swiftlint").dup
command << " #{params[:mode]}"
command << supported_option_switch(params, :strict, "0.9.2", true)
command << " --config #{params[:config_file].shellescape}" if params[:config_file]
Expand Down Expand Up @@ -39,7 +39,7 @@ def self.run(params)

# Get current SwiftLint version
def self.swiftlint_version(executable: nil)
binary = executable.nil? ? 'swiftlint' : executable
binary = executable || 'swiftlint'
Gem::Version.new(`#{binary} version`.chomp)
end

Expand Down
20 changes: 20 additions & 0 deletions fastlane/spec/actions_specs/swiftlint_spec.rb
Expand Up @@ -29,6 +29,26 @@

expect(result).to eq("swiftlint lint --strict")
end

it "adds strict option for custom executable" do
CUSTOM_EXECUTABLE_NAME = "custom_executable"

# Override the already overridden swiftlint_version method to check
# that the correct exectuable is being passed in as a parameter.
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version) { |params|
expect(params[:executable]).to eq(CUSTOM_EXECUTABLE_NAME)
swiftlint_gem_version
}

result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: true,
executable: '#{CUSTOM_EXECUTABLE_NAME}'
)
end").runner.execute(:test)

expect(result).to eq("#{CUSTOM_EXECUTABLE_NAME} lint --strict")
end
end

context "when specify false for strict option" do
Expand Down

0 comments on commit b6e1aa2

Please sign in to comment.