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
fefbe452
Commit
fefbe452
authored
Dec 28, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PodfileValidator] Fix abstract-only dependency check
parent
fedede87
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
21 deletions
+124
-21
Gemfile.lock
Gemfile.lock
+1
-1
podfile_validator.rb
lib/cocoapods/installer/podfile_validator.rb
+5
-12
podfile_validator_spec.rb
spec/unit/installer/podfile_validator_spec.rb
+118
-8
No files found.
Gemfile.lock
View file @
fefbe452
...
...
@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 9
30de7aeb3f50eccf6d65b4d479daa3f5a956f87
revision: 9
fd6c128f989655cf48b07f7145d73ad02ab0694
branch: seg-podfile-refactor
specs:
cocoapods-core (0.39.0)
...
...
lib/cocoapods/installer/podfile_validator.rb
View file @
fefbe452
...
...
@@ -112,18 +112,11 @@ module Pod
end
def
validate_no_abstract_only_pods!
abstract_pods
=
->
(
target_definition
)
do
if
!
target_definition
.
abstract?
||
!
target_definition
.
children
.
empty?
target_definition
.
children
.
flat_map
do
|
td
|
abstract_pods
[
td
]
end
else
target_definition
.
dependencies
end
end
pods
=
podfile
.
root_target_definitions
.
flat_map
(
&
abstract_pods
).
uniq
pods
.
each
do
|
pod
|
add_error
"The dependency `
#{
pod
}
` is not used in any concrete target."
all_dependencies
=
podfile
.
dependencies
concrete_dependencies
=
podfile
.
target_definition_list
.
reject
(
&
:abstract?
).
flat_map
(
&
:dependencies
).
uniq
abstract_only_dependencies
=
all_dependencies
-
concrete_dependencies
abstract_only_dependencies
.
each
do
|
dep
|
add_error
"The dependency `
#{
dep
}
` is not used in any concrete target."
end
end
end
...
...
spec/unit/installer/podfile_validator_spec.rb
View file @
fefbe452
...
...
@@ -63,14 +63,124 @@ module Pod
end
end
it
'warns if the podfile does not contain any dependency'
do
podfile
=
Pod
::
Podfile
.
new
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
validator
.
warnings
.
should
==
[
'The Podfile does not contain any dependencies.'
]
describe
'empty podfiles'
do
it
'warns if the podfile does not contain any dependency'
do
podfile
=
Pod
::
Podfile
.
new
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
validator
.
warnings
.
should
==
[
'The Podfile does not contain any dependencies.'
]
end
end
describe
'abstract-only dependencies'
do
it
'errors when there is only a root target'
do
podfile
=
Pod
::
Podfile
.
new
do
pod
'Alamofire'
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The dependency `Alamofire` is not used in any concrete target.'
]
end
it
'errors when there are only abstract targets'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The dependency `Alamofire` is not used in any concrete target.'
]
end
it
'does not error when an abstract target has concrete children with complete inheritance'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
target
'Concrete'
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
end
it
'errors when an abstract target has concrete children with no inheritance'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
target
'Concrete'
do
inherit!
:none
end
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The dependency `Alamofire` is not used in any concrete target.'
]
end
it
'errors when an abstract target has concrete children with only search_paths inheritance'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
target
'Concrete'
do
inherit!
:search_paths
end
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
not
.
be
.
valid
validator
.
errors
.
should
==
[
'The dependency `Alamofire` is not used in any concrete target.'
]
end
it
'does not error when an abstract target has multiple children with varied inheritance'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
target
'Concrete'
do
inherit!
:none
end
target
'Other Concrete'
do
end
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
end
it
'does not error when an abstract target has multiple children with varied inheritance'
do
podfile
=
Pod
::
Podfile
.
new
do
abstract_target
'Abstract'
do
pod
'Alamofire'
target
'Concrete'
do
inherit!
:search_paths
end
target
'Other Concrete'
do
end
end
end
validator
=
Installer
::
PodfileValidator
.
new
(
podfile
)
validator
.
validate
validator
.
should
.
be
.
valid
validator
.
errors
.
should
.
be
.
empty
end
end
end
end
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