Commit 8048d060 authored by Marius Rackwitz's avatar Marius Rackwitz

[Validator] Add option fail_fast to fail on first platform or subspec

parent 6a456add
...@@ -123,6 +123,12 @@ module Pod ...@@ -123,6 +123,12 @@ module Pod
# #
attr_accessor :no_clean attr_accessor :no_clean
# @return [Bool] whether the linter should fail as soon as the first build
# variant causes an error. Helpful for i.e. multi-platforms specs,
# specs with subspecs.
#
attr_accessor :fail_fast
# @return [Bool] whether the validation should be performed against the root of # @return [Bool] whether the validation should be performed against the root of
# the podspec instead to its original source. # the podspec instead to its original source.
# #
...@@ -208,7 +214,7 @@ module Pod ...@@ -208,7 +214,7 @@ module Pod
validate_documentation_url(spec) validate_documentation_url(spec)
validate_docset_url(spec) validate_docset_url(spec)
spec.available_platforms.each do |platform| valid = spec.available_platforms.send(fail_fast ? :all? : :each) do |platform|
UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
@consumer = spec.consumer(platform) @consumer = spec.consumer(platform)
setup_validation_environment setup_validation_environment
...@@ -217,14 +223,16 @@ module Pod ...@@ -217,14 +223,16 @@ module Pod
build_pod build_pod
check_file_patterns check_file_patterns
tear_down_validation_environment tear_down_validation_environment
validated?
end end
return false if fail_fast && !valid
perform_extensive_subspec_analysis(spec) unless @no_subspecs perform_extensive_subspec_analysis(spec) unless @no_subspecs
end end
# Recursively perform the extensive analysis on all subspecs # Recursively perform the extensive analysis on all subspecs
# #
def perform_extensive_subspec_analysis(spec) def perform_extensive_subspec_analysis(spec)
spec.subspecs.each do |subspec| spec.subspecs.send(fail_fast ? :all? : :each) do |subspec|
@subspec_name = subspec.name @subspec_name = subspec.name
perform_extensive_analysis(subspec) perform_extensive_analysis(subspec)
end end
......
...@@ -273,6 +273,17 @@ module Pod ...@@ -273,6 +273,17 @@ module Pod
validator.validate validator.validate
end end
it 'builds the pod only once if the first fails with fail_fast' do
Validator.any_instance.unstub(:xcodebuild)
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:validate_url)
validator.fail_fast = true
validator.expects(:xcodebuild).once.returns('file.m:1:1: error: Pretended!')
validator.validate
validator.result_type.should == :error
end
it 'uses the deployment target of the specification' do it 'uses the deployment target of the specification' do
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url)) validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:validate_url) validator.stubs(:validate_url)
...@@ -284,6 +295,7 @@ module Pod ...@@ -284,6 +295,7 @@ module Pod
it 'uses the deployment target of the current subspec' do it 'uses the deployment target of the current subspec' do
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url)) validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.instance_variable_set(:@results, [])
validator.stubs(:validate_url) validator.stubs(:validate_url)
validator.stubs(:validate_screenshots) validator.stubs(:validate_screenshots)
validator.stubs(:check_file_patterns) validator.stubs(:check_file_patterns)
...@@ -365,7 +377,7 @@ module Pod ...@@ -365,7 +377,7 @@ module Pod
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url)) validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:check_file_patterns) validator.stubs(:check_file_patterns)
validator.stubs(:validate_url) validator.stubs(:validate_url)
validator.stubs(:`).returns('Output') validator.expects(:`).with('which xcodebuild').twice.returns('/usr/bin/xcodebuild')
status = mock status = mock
status.stubs(:success?).returns(false) status.stubs(:success?).returns(false)
validator.stubs(:_xcodebuild).returns(['Output', status]) validator.stubs(:_xcodebuild).returns(['Output', status])
...@@ -487,6 +499,7 @@ module Pod ...@@ -487,6 +499,7 @@ module Pod
end end
def setup_validator def setup_validator
@validator.instance_variable_set(:@results, [])
@validator.stubs(:validate_url) @validator.stubs(:validate_url)
@validator.stubs(:validate_screenshots) @validator.stubs(:validate_screenshots)
@validator.stubs(:check_file_patterns) @validator.stubs(:check_file_patterns)
......
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