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
f97108e5
Commit
f97108e5
authored
Apr 03, 2018
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Add an API that just returns AggregateTargets from a sandbox
parent
6ed5ddf1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
3 deletions
+119
-3
installer.rb
lib/cocoapods/installer.rb
+27
-2
installer_spec.rb
spec/unit/installer_spec.rb
+92
-1
No files found.
lib/cocoapods/installer.rb
View file @
f97108e5
...
@@ -66,8 +66,8 @@ module Pod
...
@@ -66,8 +66,8 @@ module Pod
# @param [Lockfile] lockfile @see #lockfile
# @param [Lockfile] lockfile @see #lockfile
#
#
def
initialize
(
sandbox
,
podfile
,
lockfile
=
nil
)
def
initialize
(
sandbox
,
podfile
,
lockfile
=
nil
)
@sandbox
=
sandbox
||
raise
(
ArgumentError
,
"need a sandbox"
)
@sandbox
=
sandbox
||
raise
(
ArgumentError
,
'need a sandbox'
)
@podfile
=
podfile
||
raise
(
ArgumentError
,
"need a podfile"
)
@podfile
=
podfile
||
raise
(
ArgumentError
,
'need a podfile'
)
@lockfile
=
lockfile
@lockfile
=
lockfile
@use_default_plugins
=
true
@use_default_plugins
=
true
...
@@ -669,5 +669,30 @@ module Pod
...
@@ -669,5 +669,30 @@ module Pod
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
public
# @!group Convenience Methods
def
self
.
targets_from_sandbox
(
sandbox
,
podfile
,
lockfile
)
raise
Informative
,
'You must run `pod install` to be able to generate target information'
unless
lockfile
new
(
sandbox
,
podfile
,
lockfile
).
instance_exec
do
plugin_sources
=
run_source_provider_hooks
analyzer
=
create_analyzer
(
plugin_sources
)
analyze
(
analyzer
)
if
analyzer
.
podfile_needs_install?
(
analyzer
.
result
)
raise
Pod
::
Informative
,
'The Podfile has changed, you must run `pod install`'
elsif
analyzer
.
sandbox_needs_install?
(
analyzer
.
result
)
raise
Pod
::
Informative
,
'The `Pods` directory is out-of-date, you must run `pod install`'
end
create_file_accessors
aggregate_targets
end
end
#-------------------------------------------------------------------------#
end
end
end
end
spec/unit/installer_spec.rb
View file @
f97108e5
...
@@ -35,7 +35,7 @@ def generate_local_podfile
...
@@ -35,7 +35,7 @@ def generate_local_podfile
platform
:ios
platform
:ios
project
SpecHelper
.
fixture
(
'SampleProject/SampleProject'
),
'Test'
=>
:debug
,
'App Store'
=>
:release
project
SpecHelper
.
fixture
(
'SampleProject/SampleProject'
),
'Test'
=>
:debug
,
'App Store'
=>
:release
target
'SampleProject'
do
target
'SampleProject'
do
pod
'Reachability'
,
:path
=>
SpecHelper
.
fixture
(
'integration/Reachability'
)
pod
'Reachability'
,
:path
=>
SpecHelper
.
fixture
(
'integration/Reachability'
)
.
to_s
target
'SampleProjectTests'
do
target
'SampleProjectTests'
do
inherit!
:search_paths
inherit!
:search_paths
end
end
...
@@ -734,5 +734,96 @@ module Pod
...
@@ -734,5 +734,96 @@ module Pod
@installer
.
install!
@installer
.
install!
end
end
end
end
#-------------------------------------------------------------------------#
describe
'.targets_from_sandbox'
do
it
'raises when there is no lockfile'
do
sandbox
=
config
.
sandbox
podfile
=
generate_podfile
lockfile
=
nil
should
.
raise
Informative
do
Installer
.
targets_from_sandbox
(
sandbox
,
podfile
,
lockfile
)
end
.
message
.
should
.
include
'You must run `pod install` to be able to generate target information'
end
it
'raises when the podfile has changed'
do
sandbox
=
config
.
sandbox
podfile
=
generate_podfile
([
'AFNetworking'
])
lockfile
=
generate_lockfile
should
.
raise
Informative
do
Installer
.
targets_from_sandbox
(
sandbox
,
podfile
,
lockfile
)
end
.
message
.
should
.
include
'The Podfile has changed, you must run `pod install`'
end
it
'raises when the sandbox has changed'
do
sandbox
=
config
.
sandbox
podfile
=
generate_podfile
lockfile
=
generate_lockfile
lockfile
.
internal_data
[
'DEPENDENCIES'
]
=
podfile
.
dependencies
.
map
(
&
:to_s
)
should
.
raise
Informative
do
Installer
.
targets_from_sandbox
(
sandbox
,
podfile
,
lockfile
)
end
.
message
.
should
.
include
'The `Pods` directory is out-of-date, you must run `pod install`'
end
it
'returns the aggregate targets without performing installation'
do
podfile
=
generate_podfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
expects
(
:integrate_user_project
)
@installer
.
install!
pod_targets
=
@installer
.
aggregate_targets
.
map
(
&
:pod_targets
)
::
SpecHelper
.
reset_config_instance
aggregate_targets
=
Installer
.
targets_from_sandbox
(
config
.
sandbox
,
podfile
,
config
.
lockfile
)
aggregate_targets
.
map
(
&
:target_definition
).
should
==
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'SampleProjectTests'
]
]
aggregate_targets
.
last
.
pod_targets
.
should
==
[]
sample_project_target
=
aggregate_targets
.
first
sample_project_target
.
pod_targets
.
map
(
&
:label
).
should
==
%w(JSONKit)
jsonkit
=
sample_project_target
.
pod_targets
.
first
jsonkit
.
sandbox
.
should
==
config
.
sandbox
jsonkit
.
file_accessors
.
flat_map
(
&
:root
).
should
==
[
config
.
sandbox
.
pod_dir
(
'JSONKit'
)]
jsonkit
.
archs
.
should
==
[]
end
it
'returns the aggregate targets without performing installation with local pods'
do
podfile
=
generate_local_podfile
lockfile
=
generate_lockfile
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
@installer
.
expects
(
:integrate_user_project
)
@installer
.
install!
pod_targets
=
@installer
.
aggregate_targets
.
map
(
&
:pod_targets
)
::
SpecHelper
.
reset_config_instance
aggregate_targets
=
Installer
.
targets_from_sandbox
(
config
.
sandbox
,
podfile
,
config
.
lockfile
)
aggregate_targets
.
map
(
&
:target_definition
).
should
==
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'SampleProjectTests'
]
]
aggregate_targets
.
last
.
pod_targets
.
should
==
[]
sample_project_target
=
aggregate_targets
.
first
sample_project_target
.
pod_targets
.
map
(
&
:label
).
should
==
%w(Reachability)
jsonkit
=
sample_project_target
.
pod_targets
.
first
jsonkit
.
sandbox
.
should
==
config
.
sandbox
jsonkit
.
file_accessors
.
flat_map
(
&
:root
).
should
==
[
config
.
sandbox
.
pod_dir
(
'Reachability'
)]
jsonkit
.
archs
.
should
==
[]
end
end
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