Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
8048d060
Commit
8048d060
authored
Apr 16, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Add option fail_fast to fail on first platform or subspec
parent
6a456add
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
validator.rb
lib/cocoapods/validator.rb
+10
-2
validator_spec.rb
spec/unit/validator_spec.rb
+14
-1
No files found.
lib/cocoapods/validator.rb
View file @
8048d060
...
@@ -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
...
...
spec/unit/validator_spec.rb
View file @
8048d060
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment