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
c2a1fe6c
Commit
c2a1fe6c
authored
Apr 18, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3412 from CocoaPods/mr-lint-fail-fast
[Linter] Allow to fail-fast
parents
b3c9bd66
55a5069a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
3 deletions
+30
-3
lib.rb
lib/cocoapods/command/lib.rb
+3
-0
lint.rb
lib/cocoapods/command/spec/lint.rb
+3
-0
validator.rb
lib/cocoapods/validator.rb
+10
-2
validator_spec.rb
spec/unit/validator_spec.rb
+14
-1
No files found.
lib/cocoapods/command/lib.rb
View file @
c2a1fe6c
...
@@ -113,6 +113,7 @@ module Pod
...
@@ -113,6 +113,7 @@ module Pod
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--fail-fast'
,
'Lint stops on the first failing platform or subspec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependant pods '
\
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependant pods '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
...
@@ -123,6 +124,7 @@ module Pod
...
@@ -123,6 +124,7 @@ module Pod
@quick
=
argv
.
flag?
(
'quick'
)
@quick
=
argv
.
flag?
(
'quick'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@fail_fast
=
argv
.
flag?
(
'fail-fast'
,
false
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
...
@@ -142,6 +144,7 @@ module Pod
...
@@ -142,6 +144,7 @@ module Pod
validator
.
local
=
true
validator
.
local
=
true
validator
.
quick
=
@quick
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
no_clean
=
!
@clean
validator
.
fail_fast
=
@fail_fast
validator
.
allow_warnings
=
@allow_warnings
validator
.
allow_warnings
=
@allow_warnings
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
only_subspec
=
@only_subspec
validator
.
only_subspec
=
@only_subspec
...
...
lib/cocoapods/command/spec/lint.rb
View file @
c2a1fe6c
...
@@ -20,6 +20,7 @@ module Pod
...
@@ -20,6 +20,7 @@ module Pod
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--fail-fast'
,
'Lint stops on the first failing platform or subspec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependant pods '
\
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependant pods '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
...
@@ -30,6 +31,7 @@ module Pod
...
@@ -30,6 +31,7 @@ module Pod
@quick
=
argv
.
flag?
(
'quick'
)
@quick
=
argv
.
flag?
(
'quick'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@fail_fast
=
argv
.
flag?
(
'fail-fast'
,
false
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
...
@@ -45,6 +47,7 @@ module Pod
...
@@ -45,6 +47,7 @@ module Pod
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
quick
=
@quick
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
no_clean
=
!
@clean
validator
.
fail_fast
=
@fail_fast
validator
.
allow_warnings
=
@allow_warnings
validator
.
allow_warnings
=
@allow_warnings
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
only_subspec
=
@only_subspec
validator
.
only_subspec
=
@only_subspec
...
...
lib/cocoapods/validator.rb
View file @
c2a1fe6c
...
@@ -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 @
c2a1fe6c
...
@@ -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