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

Don't rely on the swiftlint executable for tests. #174

Merged
merged 7 commits into from Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ext/swiftlint/Rakefile
Expand Up @@ -16,7 +16,7 @@ namespace :swiftlint do
SWIFTLINT_MD5_HASH = DangerSwiftlint::SWIFTLINT_HASH

puts "Downloading swiftlint@#{VERSION}"
sh "sh #{SCRIPT_PATH}/downloadSwiftlint.sh -u #{URL} -d #{DESTINATION} -a #{ASSET} -dh #{SWIFTLINT_MD5_HASH}"
sh "#{SCRIPT_PATH}/downloadSwiftlint.sh -u #{URL} -d #{DESTINATION} -a #{ASSET} -dh #{SWIFTLINT_MD5_HASH}"
end
end

Expand Down
11 changes: 10 additions & 1 deletion ext/swiftlint/downloadSwiftlint.sh
Expand Up @@ -34,7 +34,16 @@ done
### Download
mkdir -p "${destination}"
curl -s -L "${url}" -o "${asset}"
if [[ ! -z "${SWIFTLINT_VERSION}" || $(md5 -q "${asset}") == "${default_hash}" ]]; then

# If macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
resulting_hash=`md5 -q ${asset}`
# Default to linux
else
resulting_hash=`md5sum ${asset} | awk '{ print $1 }'`
fi

if [[ ! -z "${SWIFTLINT_VERSION}" || "$resulting_hash" == "${default_hash}" ]]; then
# if another version is set || our hardcoded hash is correct
unzip -o -q "${asset}" -d "${destination}"
else
Expand Down
2 changes: 2 additions & 0 deletions spec/danger_plugin_spec.rb
Expand Up @@ -220,13 +220,15 @@ module Danger
end

it 'crashes if renamed_files is not configured properly' do
allow_any_instance_of(Swiftlint).to receive(:lint).and_return('')
allow(@swiftlint.git).to receive(:modified_files).and_return([
'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift'
])
expect { @swiftlint.lint_files }.to raise_error(NoMethodError)
end

it 'does not crash if a modified file was renamed' do
allow_any_instance_of(Swiftlint).to receive(:lint).and_return('')
allow(@swiftlint.git).to receive(:modified_files).and_return([
'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift'
])
Expand Down