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
881c98bf
Commit
881c98bf
authored
Apr 16, 2018
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track test dependent targets per test spec instead of flat list
parent
76c47a81
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
28 deletions
+38
-28
installer.rb
lib/cocoapods/installer.rb
+3
-1
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+10
-6
pod_target.rb
lib/cocoapods/target/pod_target.rb
+11
-7
pod_xcconfig_spec.rb
spec/unit/generator/xcconfig/pod_xcconfig_spec.rb
+8
-8
installer_spec.rb
spec/unit/installer_spec.rb
+3
-3
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+3
-3
No files found.
lib/cocoapods/installer.rb
View file @
881c98bf
...
...
@@ -224,7 +224,9 @@ module Pod
#
def
pod_targets
aggregate_target_pod_targets
=
aggregate_targets
.
flat_map
(
&
:pod_targets
)
test_dependent_targets
=
aggregate_target_pod_targets
.
flat_map
(
&
:test_dependent_targets
)
test_dependent_targets
=
aggregate_target_pod_targets
.
flat_map
do
|
pod_target
|
pod_target
.
test_dependent_targets_by_spec_name
.
values
.
flatten
end
(
aggregate_target_pod_targets
+
test_dependent_targets
).
uniq
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
881c98bf
...
...
@@ -513,10 +513,12 @@ module Pod
pod_targets
.
each
do
|
target
|
all_specs
=
all_resolver_specs
.
group_by
(
&
:name
)
dependencies
=
transitive_dependencies_for_specs
(
target
.
non_test_specs
.
to_set
,
target
.
platform
,
all_specs
.
dup
).
group_by
(
&
:root
)
test_dependencies
=
transitive_dependencies_for_specs
(
target
.
test_specs
.
to_set
,
target
.
platform
,
all_specs
.
dup
).
group_by
(
&
:root
)
test_dependencies
.
delete_if
{
|
k
|
dependencies
.
key?
k
}
target
.
dependent_targets
=
filter_dependencies
(
dependencies
,
pod_targets_by_name
,
target
)
target
.
test_dependent_targets
=
filter_dependencies
(
test_dependencies
,
pod_targets_by_name
,
target
)
target
.
test_dependent_targets_by_spec_name
=
target
.
test_specs
.
each_with_object
({})
do
|
test_spec
,
hash
|
test_dependencies
=
transitive_dependencies_for_specs
([
test_spec
],
target
.
platform
,
all_specs
).
group_by
(
&
:root
)
test_dependencies
.
delete_if
{
|
k
|
dependencies
.
key?
k
}
hash
[
test_spec
.
name
]
=
filter_dependencies
(
test_dependencies
,
pod_targets_by_name
,
target
)
end
end
else
dedupe_cache
=
{}
...
...
@@ -529,10 +531,12 @@ module Pod
pod_targets
.
each
do
|
target
|
all_specs
=
specs
.
map
(
&
:spec
).
group_by
(
&
:name
)
dependencies
=
transitive_dependencies_for_specs
(
target
.
non_test_specs
.
to_set
,
target
.
platform
,
all_specs
.
dup
).
group_by
(
&
:root
)
test_dependencies
=
transitive_dependencies_for_specs
(
target
.
test_specs
.
to_set
,
target
.
platform
,
all_specs
.
dup
).
group_by
(
&
:root
)
test_dependencies
.
delete_if
{
|
k
|
dependencies
.
key?
k
}
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?
}
target
.
test_dependent_targets_by_spec_name
=
target
.
test_specs
.
each_with_object
({})
do
|
test_spec
,
hash
|
test_dependencies
=
transitive_dependencies_for_specs
(
target
.
test_specs
.
to_set
,
target
.
platform
,
all_specs
.
dup
).
group_by
(
&
:root
)
test_dependencies
.
delete_if
{
|
k
|
dependencies
.
key?
k
}
hash
[
test_spec
.
name
]
=
pod_targets
.
reject
{
|
t
|
test_dependencies
[
t
.
root_spec
].
nil?
}
end
end
end
end
...
...
lib/cocoapods/target/pod_target.rb
View file @
881c98bf
...
...
@@ -43,10 +43,9 @@ module Pod
#
attr_accessor
:dependent_targets
# @return [Array<PodTarget>] the targets that this target has a test dependency
# upon.
# @return [Hash{String=>Array<PodTarget>}] all target dependencies by test spec name.
#
attr_accessor
:test_dependent_targets
attr_accessor
:test_dependent_targets
_by_spec_name
# Initialize a new instance
#
...
...
@@ -73,7 +72,7 @@ module Pod
@test_specs
,
@non_test_specs
=
@specs
.
partition
(
&
:test_specification?
)
@build_headers
=
Sandbox
::
HeadersStore
.
new
(
sandbox
,
'Private'
,
:private
)
@dependent_targets
=
[]
@test_dependent_targets
=
[]
@test_dependent_targets
_by_spec_name
=
{}
@build_config_cache
=
{}
end
...
...
@@ -92,7 +91,12 @@ module Pod
else
target
=
PodTarget
.
new
(
sandbox
,
host_requires_frameworks
,
user_build_configurations
,
archs
,
platform
,
specs
,
[
target_definition
],
file_accessors
,
target_definition
.
label
)
target
.
dependent_targets
=
dependent_targets
.
flat_map
{
|
pt
|
pt
.
scoped
(
cache
)
}.
select
{
|
pt
|
pt
.
target_definitions
==
[
target_definition
]
}
target
.
test_dependent_targets
=
test_dependent_targets
.
flat_map
{
|
pt
|
pt
.
scoped
(
cache
)
}.
select
{
|
pt
|
pt
.
target_definitions
==
[
target_definition
]
}
target
.
test_dependent_targets_by_spec_name
=
Hash
[
test_dependent_targets_by_spec_name
.
map
do
|
spec_name
,
test_pod_targets
|
scoped_test_pod_targets
=
test_pod_targets
.
flat_map
do
|
test_pod_target
|
test_pod_target
.
scoped
(
cache
).
select
{
|
pt
|
pt
.
target_definitions
==
[
target_definition
]
}
end
[
spec_name
,
scoped_test_pod_targets
]
end
]
cache
[
cache_key
]
=
target
end
end
...
...
@@ -448,10 +452,10 @@ module Pod
#
def
recursive_test_dependent_targets
@recursive_test_dependent_targets
||=
begin
targets
=
test_dependent_targets
.
clone
targets
=
test_dependent_targets
_by_spec_name
.
values
.
flatten
.
clone
targets
.
each
do
|
target
|
target
.
test_dependent_targets
.
each
do
|
t
|
target
.
test_dependent_targets
_by_spec_name
.
values
.
flatten
.
each
do
|
t
|
targets
.
push
(
t
)
unless
t
==
self
||
targets
.
include?
(
t
)
end
end
...
...
spec/unit/generator/xcconfig/pod_xcconfig_spec.rb
View file @
881c98bf
...
...
@@ -235,14 +235,14 @@ module Pod
end
it
'includes other ld flags for test dependent targets'
do
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
true
)
xcconfig
=
generator
.
generate
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
==
'-ObjC -l"CoconutLib" -l"monkey" -framework "dynamic-monkey"'
end
it
'adds settings for test dependent targets'
do
@coconut_pod_target
.
test_dependent_targets
=
[
@banana_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@banana_pod_target
]
}
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
true
)
xcconfig
=
generator
.
generate
xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
...
...
@@ -251,7 +251,7 @@ module Pod
it
'adds settings for test dependent targets excluding the parents targets'
do
@coconut_pod_target
.
dependent_targets
=
[
@banana_pod_target
]
@coconut_pod_target
.
test_dependent_targets
=
[
@banana_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@banana_pod_target
]
}
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
true
)
xcconfig
=
generator
.
generate
xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'$(inherited) "${PODS_ROOT}/../../spec/fixtures/banana-lib"'
...
...
@@ -267,7 +267,7 @@ module Pod
@coconut_pod_target
.
stubs
(
:defines_module?
).
returns
(
false
)
@coconut_pod_target
.
build_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
sandbox
.
public_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
@coconut_pod_target
.
dependent_targets
=
[
@banana_pod_target
]
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
true
)
xcconfig
=
generator
.
generate
...
...
@@ -288,7 +288,7 @@ module Pod
@coconut_pod_target
.
stubs
(
:defines_module?
).
returns
(
false
)
@coconut_pod_target
.
build_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
sandbox
.
public_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
@coconut_pod_target
.
dependent_targets
=
[
@banana_pod_target
]
# This is not an test xcconfig so it should exclude header search paths for the 'monkey' pod
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
false
)
...
...
@@ -309,7 +309,7 @@ module Pod
@coconut_pod_target
.
stubs
(
:defines_module?
).
returns
(
true
)
@coconut_pod_target
.
build_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
sandbox
.
public_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
@coconut_pod_target
.
dependent_targets
=
[
@banana_pod_target
]
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
true
)
xcconfig
=
generator
.
generate
...
...
@@ -326,7 +326,7 @@ module Pod
@coconut_pod_target
.
stubs
(
:defines_module?
).
returns
(
true
)
@coconut_pod_target
.
build_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
sandbox
.
public_headers
.
add_search_path
(
'CoconutLib'
,
Platform
.
ios
)
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
@coconut_pod_target
.
dependent_targets
=
[
@banana_pod_target
]
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
,
false
)
xcconfig
=
generator
.
generate
...
...
@@ -335,7 +335,7 @@ module Pod
end
it
'does not include other ld flags for test dependent targets if its not a test xcconfig'
do
@coconut_pod_target
.
test_dependent_targets
=
[
@monkey_pod_target
]
@coconut_pod_target
.
test_dependent_targets
_by_spec_name
=
{
@coconut_test_spec
.
name
=>
[
@monkey_pod_target
]
}
generator
=
PodXCConfig
.
new
(
@coconut_pod_target
)
xcconfig
=
generator
.
generate
xcconfig
.
to_hash
[
'LIBRARY_SEARCH_PATHS'
].
should
.
be
.
nil
...
...
spec/unit/installer_spec.rb
View file @
881c98bf
...
...
@@ -183,9 +183,9 @@ module Pod
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
]
)
pod_target_one
=
stub
(
'PodTarget1'
,
:test_dependent_targets_by_spec_name
=>
{}
)
pod_target_three
=
stub
(
'PodTarget2'
,
:test_dependent_targets_by_spec_name
=>
{}
)
pod_target_two
=
stub
(
'PodTarget3'
,
:test_dependent_targets_by_spec_name
=>
{
'TestSpec1'
=>
[
pod_target_three
]
}
)
aggregate_target
=
stub
(
:pod_targets
=>
[
pod_target_one
,
pod_target_two
])
result
=
stub
(
:targets
=>
[
aggregate_target
])
...
...
spec/unit/target/pod_target_spec.rb
View file @
881c98bf
...
...
@@ -467,7 +467,7 @@ module Pod
@pod_dependency
=
fixture_pod_target
(
'orange-framework/OrangeFramework.podspec'
,
false
,
{},
[],
Platform
.
ios
,
@pod_target
.
target_definitions
)
@test_pod_dependency
=
fixture_pod_target
(
'matryoshka/matryoshka.podspec'
,
false
,
{},
[],
Platform
.
ios
,
@pod_target
.
target_definitions
)
@pod_target
.
dependent_targets
=
[
@pod_dependency
]
@pod_target
.
test_dependent_targets
=
[
@test_pod_dependency
]
@pod_target
.
test_dependent_targets
_by_spec_name
=
{
@pod_dependency
.
name
=>
[
@test_pod_dependency
]
}
end
it
'resolves simple dependencies'
do
...
...
@@ -478,8 +478,8 @@ module Pod
scoped_pod_target
=
@pod_target
.
scoped
scoped_pod_target
.
first
.
dependent_targets
.
count
.
should
==
1
scoped_pod_target
.
first
.
dependent_targets
.
first
.
name
.
should
==
'OrangeFramework-Pods'
scoped_pod_target
.
first
.
test_dependent_targets
.
count
.
should
==
1
scoped_pod_target
.
first
.
test_dependent_targets
.
first
.
name
.
should
==
'matryoshka-Pods'
scoped_pod_target
.
first
.
test_dependent_targets
_by_spec_name
.
count
.
should
==
1
scoped_pod_target
.
first
.
test_dependent_targets
_by_spec_name
[
'OrangeFramework'
]
.
first
.
name
.
should
==
'matryoshka-Pods'
end
describe
'With cyclic dependencies'
do
...
...
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