Commit 61afb0d9 authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #6971 from CocoaPods/dani_validation

Fix validation when using --swift-version
parents 191eff09 2dd3f607
...@@ -26,6 +26,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -26,6 +26,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6948](https://github.com/CocoaPods/CocoaPods/pull/6948) [#6948](https://github.com/CocoaPods/CocoaPods/pull/6948)
* Fix validation warnings when using --swift-version
[Danielle Tomlinson](https://github.com/dantoml)
[#6971](https://github.com/CocoaPods/CocoaPods/issue/6971)
## 1.3.1 (2017-08-02) ## 1.3.1 (2017-08-02)
##### Enhancements ##### Enhancements
......
...@@ -14,6 +14,10 @@ module Pod ...@@ -14,6 +14,10 @@ module Pod
class Validator class Validator
include Config::Mixin include Config::Mixin
# The default version of Swift to use when linting pods
#
DEFAULT_SWIFT_VERSION = '3.0'.freeze
# @return [Specification::Linter] the linter instance from CocoaPods # @return [Specification::Linter] the linter instance from CocoaPods
# Core. # Core.
# #
...@@ -252,7 +256,12 @@ module Pod ...@@ -252,7 +256,12 @@ module Pod
# @return [String] the SWIFT_VERSION to use for validation. # @return [String] the SWIFT_VERSION to use for validation.
# #
def swift_version def swift_version
@swift_version ||= dot_swift_version || '3.0' return @swift_version if defined?(@swift_version)
if version = dot_swift_version
@swift_version = version
else
DEFAULT_SWIFT_VERSION
end
end end
# Set the SWIFT_VERSION that should be used to validate the pod. # Set the SWIFT_VERSION that should be used to validate the pod.
...@@ -386,7 +395,7 @@ module Pod ...@@ -386,7 +395,7 @@ module Pod
end end
def validate_dot_swift_version def validate_dot_swift_version
if !used_swift_version.nil? && dot_swift_version.nil? if !used_swift_version.nil? && @swift_version.nil?
warning(:swift_version, warning(:swift_version,
'The validator for Swift projects uses ' \ 'The validator for Swift projects uses ' \
'Swift 3.0 by default, if you are using a different version of ' \ 'Swift 3.0 by default, if you are using a different version of ' \
......
...@@ -931,7 +931,27 @@ module Pod ...@@ -931,7 +931,27 @@ module Pod
validator.results.count.should == 0 validator.results.count.should == 0
end end
it 'fails without the presence of a .swift-version file for Swift Pods' do describe 'with a user provided swift-version' do
it 'succeeds with a --swift-version provided value' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod
validator.swift_version = '3.1.0'
validator.validate
validator.results.count.should == 0
end
it 'succeeds with a .swift-version file' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.count.should == 0
end
end
describe 'wihout a user provided swift version' do
it 'warns for Swift Pods' do
Specification.any_instance.stubs(:deployment_target).returns('9.0') Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod validator = test_swiftpod
...@@ -946,13 +966,6 @@ module Pod ...@@ -946,13 +966,6 @@ module Pod
'to set the version for your Pod. For example to use Swift 2.3, ' \ 'to set the version for your Pod. For example to use Swift 2.3, ' \
"run: \n `echo \"2.3\" > .swift-version`" "run: \n `echo \"2.3\" > .swift-version`"
end end
it 'succeeds with the presence of a .swift-version file for Swift Pods' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod_with_dot_swift_version
validator.validate
validator.results.count.should == 0
end end
describe '#swift_version' do describe '#swift_version' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment