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
302a9ddf
Commit
302a9ddf
authored
May 18, 2017
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aggregate targets should not include pod targets only used by tests
parent
bb313c52
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
15 deletions
+74
-15
CHANGELOG.md
CHANGELOG.md
+4
-0
pod_xcconfig.rb
lib/cocoapods/generator/xcconfig/pod_xcconfig.rb
+2
-2
installer.rb
lib/cocoapods/installer.rb
+3
-1
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+21
-5
pods_project_generator.rb
lib/cocoapods/installer/xcode/pods_project_generator.rb
+1
-1
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+15
-0
pods_project_generator_spec.rb
spec/unit/installer/xcode/pods_project_generator_spec.rb
+11
-6
installer_spec.rb
spec/unit/installer_spec.rb
+17
-0
No files found.
CHANGELOG.md
View file @
302a9ddf
...
...
@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6727
](
https://github.com/CocoaPods/CocoaPods/pull/6727
)
*
Aggregate targets should not include pod targets only used by tests
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6726
](
https://github.com/CocoaPods/CocoaPods/pull/6726
)
*
Add support for test target creation in the pods project generator
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6703
](
https://github.com/CocoaPods/CocoaPods/pull/6703
)
...
...
lib/cocoapods/generator/xcconfig/pod_xcconfig.rb
View file @
302a9ddf
...
...
@@ -72,8 +72,8 @@ module Pod
@xcconfig
.
merge!
XCConfigHelper
.
settings_for_dependent_targets
(
target
,
target
.
recursive_dependent_targets
)
if
@test_xcconfig
@xcconfig
.
merge!
XCConfigHelper
.
settings_for_dependent_targets
(
target
,
target
.
test_dependent_targets
)
XCConfigHelper
.
generate_vendored_build_settings
(
nil
,
target
.
test_dependent_targets
,
@xcconfig
)
XCConfigHelper
.
generate_other_ld_flags
(
nil
,
target
.
test_dependent_targets
,
@xcconfig
)
XCConfigHelper
.
generate_vendored_build_settings
(
nil
,
[
target
,
*
target
.
test_dependent_targets
]
,
@xcconfig
)
XCConfigHelper
.
generate_other_ld_flags
(
nil
,
[
target
,
*
target
.
test_dependent_targets
]
,
@xcconfig
)
XCConfigHelper
.
generate_ld_runpath_search_paths
(
target
,
false
,
true
,
@xcconfig
)
end
@xcconfig
...
...
lib/cocoapods/installer.rb
View file @
302a9ddf
...
...
@@ -218,7 +218,9 @@ module Pod
# generated as result of the analyzer.
#
def
pod_targets
aggregate_targets
.
map
(
&
:pod_targets
).
flatten
.
uniq
aggregate_target_pod_targets
=
aggregate_targets
.
map
(
&
:pod_targets
).
flatten
test_dependent_targets
=
aggregate_target_pod_targets
.
map
(
&
:test_dependent_targets
).
flatten
(
aggregate_target_pod_targets
+
test_dependent_targets
).
uniq
end
# @return [Array<Specification>] The specifications that where installed.
...
...
lib/cocoapods/installer/analyzer.rb
View file @
302a9ddf
...
...
@@ -428,12 +428,32 @@ module Pod
end
target
.
pod_targets
=
pod_targets
.
select
do
|
pod_target
|
pod_target
.
target_definitions
.
include?
(
target_definition
)
target_definition_included
=
pod_target
.
target_definitions
.
include?
(
target_definition
)
explicitly_defined_in_target_definition
=
target_definition
.
non_inherited_dependencies
.
map
(
&
:name
).
include?
(
pod_target
.
name
)
test_pod_target_only
=
pod_target_test_only?
(
pod_target
,
pod_targets
)
target_definition_included
&&
(
explicitly_defined_in_target_definition
||
!
test_pod_target_only
)
end
target
end
# Returns true if a pod target is only used by other pod targets as a test dependency and therefore should
# not be included as part of the aggregate target.
#
# @param [PodTarget] pod_target
# the pod target being queried
#
# @param [Array<PodTarget>] pod_targets
# the array of pod targets to check against
#
# @return [Boolean] if the pod target is only referenced from test dependencies.
#
def
pod_target_test_only?
(
pod_target
,
pod_targets
)
source
=
pod_targets
.
any?
{
|
pt
|
pt
.
dependent_targets
.
map
(
&
:name
).
include?
(
pod_target
.
name
)
}
test
=
pod_targets
.
any?
{
|
pt
|
pt
.
test_dependent_targets
.
map
(
&
:name
).
include?
(
pod_target
.
name
)
}
!
source
&&
test
end
# Setup the pod targets for an aggregate target. Deduplicates resulting
# targets by grouping by platform and subspec by their root
# to create a {PodTarget} for each spec.
...
...
@@ -472,8 +492,6 @@ module Pod
test_dependencies
=
transitive_dependencies_for_specs
(
target
.
specs
.
select
(
&
:test_specification?
),
target
.
platform
,
all_specs
).
group_by
(
&
:root
)
target
.
dependent_targets
=
filter_dependencies
(
dependencies
,
pod_targets_by_name
,
target
)
target
.
test_dependent_targets
=
filter_dependencies
(
test_dependencies
,
pod_targets_by_name
,
target
)
# Test dependendent targets include our own target as a test dependency.
target
.
test_dependent_targets
<<
target
end
else
dedupe_cache
=
{}
...
...
@@ -488,8 +506,6 @@ module Pod
test_dependencies
=
transitive_dependencies_for_specs
(
target
.
specs
.
select
(
&
:test_specification?
),
target
.
platform
,
all_specs
).
group_by
(
&
:root
)
target
.
dependent_targets
=
pod_targets
.
reject
{
|
t
|
dependencies
[
t
.
root_spec
].
nil?
}
target
.
test_dependent_targets
=
pod_targets
.
reject
{
|
t
|
test_dependencies
[
t
.
root_spec
].
nil?
}
# Test dependendent targets include our own target as a test dependency.
target
.
test_dependent_targets
<<
target
end
end
end
...
...
lib/cocoapods/installer/xcode/pods_project_generator.rb
View file @
302a9ddf
...
...
@@ -211,7 +211,7 @@ module Pod
add_dependent_targets_to_native_target
(
pod_target
.
dependent_targets
,
pod_target
.
native_target
,
is_app_extension
,
pod_target
.
requires_frameworks?
,
frameworks_group
)
pod_target
.
test_native_targets
.
each
do
|
test_native_target
|
add_dependent_targets_to_native_target
(
pod_target
.
test_dependent_targets
,
test_native_target
,
false
,
pod_target
.
requires_frameworks?
,
frameworks_group
)
add_dependent_targets_to_native_target
(
[
pod_target
,
*
pod_target
.
test_dependent_targets
]
,
test_native_target
,
false
,
pod_target
.
requires_frameworks?
,
frameworks_group
)
end
end
end
...
...
spec/unit/installer/analyzer_spec.rb
View file @
302a9ddf
...
...
@@ -672,6 +672,21 @@ module Pod
#-------------------------------------------------------------------------#
it
'handles test only pod targets'
do
pod_target_one
=
stub
(
:name
=>
'Pod1'
,
:dependent_targets
=>
[],
:test_dependent_targets
=>
[])
pod_target_two
=
stub
(
:name
=>
'Pod2'
,
:dependent_targets
=>
[],
:test_dependent_targets
=>
[])
pod_target_three
=
stub
(
:name
=>
'Pod3'
,
:dependent_targets
=>
[
pod_target_one
,
pod_target_two
],
:test_dependent_targets
=>
[])
pod_target_four
=
stub
(
:name
=>
'Pod4'
,
:dependent_targets
=>
[],
:test_dependent_targets
=>
[
pod_target_three
])
all_pod_targets
=
[
pod_target_one
,
pod_target_two
,
pod_target_three
,
pod_target_four
]
@analyzer
.
send
(
:pod_target_test_only?
,
pod_target_one
,
all_pod_targets
).
should
.
be
.
false
@analyzer
.
send
(
:pod_target_test_only?
,
pod_target_two
,
all_pod_targets
).
should
.
be
.
false
@analyzer
.
send
(
:pod_target_test_only?
,
pod_target_three
,
all_pod_targets
).
should
.
be
.
true
@analyzer
.
send
(
:pod_target_test_only?
,
pod_target_four
,
all_pod_targets
).
should
.
be
.
false
end
#-------------------------------------------------------------------------#
describe
'extension targets'
do
before
do
SpecHelper
.
create_sample_app_copy_from_fixture
(
'Sample Extensions Project'
)
...
...
spec/unit/installer/xcode/pods_project_generator_spec.rb
View file @
302a9ddf
...
...
@@ -264,8 +264,11 @@ module Pod
mock_native_target
=
mock
(
'CoconutLib'
)
mock_test_native_target
=
mock
(
'CoconutLib-Unit-Tests'
)
dependent_target
=
mock
(
'dependent-target'
,
:should_build?
=>
true
,
:native_target
=>
'DependentNativeTarget'
)
test_dependent_target
=
mock
(
'dependent-test-target'
,
:should_build?
=>
true
,
:native_target
=>
'TestDependentNativeTarget'
)
dependent_native_target
=
mock
(
'DependentNativeTarget'
)
test_dependent_native_target
=
mock
(
'TestDependentNativeTarget'
)
dependent_target
=
mock
(
'dependent-target'
,
:should_build?
=>
true
,
:native_target
=>
dependent_native_target
)
test_dependent_target
=
mock
(
'dependent-test-target'
,
:should_build?
=>
true
,
:native_target
=>
test_dependent_native_target
)
@pod_target
.
stubs
(
:native_target
).
returns
(
mock_native_target
)
@pod_target
.
stubs
(
:test_native_targets
).
returns
([
mock_test_native_target
])
...
...
@@ -274,11 +277,13 @@ module Pod
@pod_target
.
stubs
(
:should_build?
=>
true
)
@mock_target
.
expects
(
:add_dependency
).
with
(
mock_native_target
)
mock_native_target
.
expects
(
:add_dependency
).
with
(
'DependentNativeTarget'
)
mock_native_target
.
expects
(
:add_dependency
).
with
(
'TestDependentNativeTarget'
).
never
mock_native_target
.
expects
(
:add_dependency
).
with
(
dependent_native_target
)
mock_native_target
.
expects
(
:add_dependency
).
with
(
test_dependent_native_target
).
never
mock_native_target
.
expects
(
:add_dependency
).
with
(
mock_native_target
).
never
mock_test_native_target
.
expects
(
:add_dependency
).
with
(
'DependentNativeTarget'
).
never
mock_test_native_target
.
expects
(
:add_dependency
).
with
(
'TestDependentNativeTarget'
)
mock_test_native_target
.
expects
(
:add_dependency
).
with
(
dependent_native_target
).
never
mock_test_native_target
.
expects
(
:add_dependency
).
with
(
test_dependent_native_target
)
mock_test_native_target
.
expects
(
:add_dependency
).
with
(
mock_native_target
)
@generator
.
send
(
:set_target_dependencies
)
end
...
...
spec/unit/installer_spec.rb
View file @
302a9ddf
...
...
@@ -158,6 +158,23 @@ module Pod
UI
.
output
.
should
.
include
'Skipping User Project Integration'
end
it
'includes pod targets from test dependent targets'
do
pod_target_one
=
stub
(
:test_dependent_targets
=>
[])
pod_target_three
=
stub
(
:test_dependent_targets
=>
[])
pod_target_two
=
stub
(
:test_dependent_targets
=>
[
pod_target_three
])
aggregate_target
=
stub
(
:pod_targets
=>
[
pod_target_one
,
pod_target_two
])
result
=
stub
(
:targets
=>
[
aggregate_target
])
analyzer
=
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@installer
.
podfile
,
@installer
.
lockfile
)
analyzer
.
stubs
(
:analyze
).
returns
(
result
)
analyzer
.
stubs
(
:result
).
returns
(
result
)
@installer
.
stubs
(
:create_analyzer
).
returns
(
analyzer
)
@installer
.
send
(
:analyze
)
@installer
.
pod_targets
.
should
==
[
pod_target_one
,
pod_target_two
,
pod_target_three
]
end
it
'prints a list of deprecated pods'
do
spec
=
Spec
.
new
spec
.
name
=
'RestKit'
...
...
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