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
266f42e1
Commit
266f42e1
authored
Nov 16, 2014
by
Eloy Durán
Committed by
Samuel E. Giddins
Nov 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Analyzer] Cleanup and improve tests for lockfile checkout options.
parent
d1d7fd8c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
382 additions
and
299 deletions
+382
-299
sandbox.rb
lib/cocoapods/sandbox.rb
+5
-1
spec_helper.rb
spec/spec_helper.rb
+2
-0
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+375
-298
No files found.
lib/cocoapods/sandbox.rb
View file @
266f42e1
...
@@ -64,8 +64,12 @@ module Pod
...
@@ -64,8 +64,12 @@ module Pod
# @return [Lockfile] the manifest which contains the information about the
# @return [Lockfile] the manifest which contains the information about the
# installed pods.
# installed pods.
#
#
attr_accessor
:manifest
def
manifest
def
manifest
Lockfile
.
from_file
(
manifest_path
)
if
manifest_path
.
exist?
@manifest
||=
begin
Lockfile
.
from_file
(
manifest_path
)
if
manifest_path
.
exist?
end
end
end
# @return [Project] the Pods project.
# @return [Project] the Pods project.
...
...
spec/spec_helper.rb
View file @
266f42e1
...
@@ -26,7 +26,9 @@ require 'bacon'
...
@@ -26,7 +26,9 @@ require 'bacon'
require
'mocha-on-bacon'
require
'mocha-on-bacon'
require
'pretty_bacon'
require
'pretty_bacon'
require
'pathname'
require
'pathname'
require
'active_support/core_ext/string/strip'
require
'active_support/core_ext/string/strip'
require
'active_support/core_ext/object/deep_dup'
ROOT
=
Pathname
.
new
(
File
.
expand_path
(
'../../'
,
__FILE__
))
ROOT
=
Pathname
.
new
(
File
.
expand_path
(
'../../'
,
__FILE__
))
$:
.
unshift
((
ROOT
+
'lib'
).
to_s
)
$:
.
unshift
((
ROOT
+
'lib'
).
to_s
)
...
...
spec/unit/installer/analyzer_spec.rb
View file @
266f42e1
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
# @return [Analyzer] the sample analyzer.
#
def
create_analyzer
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
,
'6.0'
xcodeproj
'SampleProject/SampleProject'
pod
'JSONKit'
,
'1.5pre'
pod
'AFNetworking'
,
'1.0.1'
pod
'SVPullToRefresh'
,
'0.4'
pod
'libextobjc/EXTKeyPathCoding'
,
'0.2.3'
end
hash
=
{}
hash
[
'PODS'
]
=
[
'JSONKit (1.5pre)'
,
'NUI (0.2.0)'
,
'SVPullToRefresh (0.4)'
]
hash
[
'DEPENDENCIES'
]
=
%w(JSONKit NUI SVPullToRefresh)
hash
[
'SPEC CHECKSUMS'
]
=
{}
hash
[
'COCOAPODS'
]
=
Pod
::
VERSION
lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@podfile
,
lockfile
)
end
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
module
Pod
module
Pod
describe
Installer
::
Analyzer
do
describe
Installer
::
Analyzer
do
before
do
@analyzer
=
create_analyzer
end
describe
'Analysis'
do
describe
'Analysis'
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
,
'6.0'
xcodeproj
'SampleProject/SampleProject'
pod
'JSONKit'
,
'1.5pre'
pod
'AFNetworking'
,
'1.0.1'
pod
'SVPullToRefresh'
,
'0.4'
pod
'libextobjc/EXTKeyPathCoding'
,
'0.2.3'
end
hash
=
{}
hash
[
'PODS'
]
=
[
'JSONKit (1.5pre)'
,
'NUI (0.2.0)'
,
'SVPullToRefresh (0.4)'
]
hash
[
'DEPENDENCIES'
]
=
%w(JSONKit NUI SVPullToRefresh)
hash
[
'SPEC CHECKSUMS'
]
=
{}
hash
[
'COCOAPODS'
]
=
Pod
::
VERSION
@lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
@analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@podfile
,
@lockfile
)
end
it
'returns whether an installation should be performed'
do
it
'returns whether an installation should be performed'
do
@analyzer
.
needs_install?
.
should
.
be
.
true
@analyzer
.
needs_install?
.
should
.
be
.
true
...
@@ -185,57 +178,6 @@ module Pod
...
@@ -185,57 +178,6 @@ module Pod
@analyzer
.
send
(
:fetch_external_sources
)
@analyzer
.
send
(
:fetch_external_sources
)
end
end
it
'raises when dependencies with the same name have different '
\
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/SEGModules.git'
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/Modules.git'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `SEGModules`/
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/SEGModules.git`
\)
}
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/Modules.git`
\)
}
end
it
'raises when dependencies with the same root name have different '
\
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit/Core'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
:git
=>
'https://github.com/segiddins/RestKit.git'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `RestKit`/
e
.
message
.
should
.
match
%r{RestKit/Core
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/segiddins/RestKit.git`
\)
}
end
it
'raises when dependencies with the same name have different '
\
'external sources with one being nil'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
'~> 0.23.0'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `RestKit`/
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
e
.
message
.
should
.
match
%r{RestKit
\(
~> 0.23.0
\)
}
end
xit
'it fetches the specification from either the sandbox or from the remote be default'
do
xit
'it fetches the specification from either the sandbox or from the remote be default'
do
dependency
=
Dependency
.
new
(
'Name'
,
:git
=>
'www.example.com'
)
dependency
=
Dependency
.
new
(
'Name'
,
:git
=>
'www.example.com'
)
ExternalSources
::
DownloaderSource
.
any_instance
.
expects
(
:specification_from_external
).
returns
(
Specification
.
new
).
once
ExternalSources
::
DownloaderSource
.
any_instance
.
expects
(
:specification_from_external
).
returns
(
Specification
.
new
).
once
...
@@ -311,301 +253,436 @@ module Pod
...
@@ -311,301 +253,436 @@ module Pod
state
.
added
.
sort
.
should
==
%w(AFNetworking JSONKit SVPullToRefresh libextobjc)
state
.
added
.
sort
.
should
==
%w(AFNetworking JSONKit SVPullToRefresh libextobjc)
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
'Private helpers'
do
describe
'Private helpers'
do
describe
'#compute_user_project_targets'
do
describe
'#compute_user_project_targets'
do
it
'uses the path specified in the target definition while computing the path of the user project'
do
it
'uses the path specified in the target definition while computing the path of the user project'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
user_project_path
=
'SampleProject/SampleProject'
target_definition
.
user_project_path
=
'SampleProject/SampleProject'
path
=
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
path
=
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
end
end
it
'raises if the user project of the target definition does not exists while computing the path of the user project'
do
it
'raises if the user project of the target definition does not exists while computing the path of the user project'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
user_project_path
=
'Test'
target_definition
.
user_project_path
=
'Test'
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
}.
should
.
raise
Informative
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find/
e
.
message
.
should
.
match
/Unable to find/
end
end
it
'if not specified in the target definition if looks if there is only one project'
do
it
'if not specified in the target definition if looks if there is only one project'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
config
.
installation_root
=
config
.
installation_root
+
'SampleProject'
config
.
installation_root
=
config
.
installation_root
+
'SampleProject'
path
=
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
path
=
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
end
end
it
'if not specified in the target definition if looks if there is only one project'
do
it
'if not specified in the target definition if looks if there is only one project'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
}.
should
.
raise
Informative
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_path
,
target_definition
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Could not.*select.*project/
e
.
message
.
should
.
match
/Could not.*select.*project/
end
end
it
'does not take aggregate targets into consideration'
do
it
'does not take aggregate targets into consideration'
do
aggregate_class
=
Xcodeproj
::
Project
::
Object
::
PBXAggregateTarget
aggregate_class
=
Xcodeproj
::
Project
::
Object
::
PBXAggregateTarget
sample_project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
sample_project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
sample_project
=
Xcodeproj
::
Project
.
open
(
sample_project_path
)
sample_project
=
Xcodeproj
::
Project
.
open
(
sample_project_path
)
sample_project
.
targets
.
map
(
&
:class
).
should
.
include
(
aggregate_class
)
sample_project
.
targets
.
map
(
&
:class
).
should
.
include
(
aggregate_class
)
native_targets
=
@analyzer
.
send
(
:native_targets
,
sample_project
).
map
(
&
:class
)
native_targets
=
@analyzer
.
send
(
:native_targets
,
sample_project
).
map
(
&
:class
)
native_targets
.
should
.
not
.
include
(
aggregate_class
)
native_targets
.
should
.
not
.
include
(
aggregate_class
)
end
end
end
end
#--------------------------------------#
#--------------------------------------#
describe
'#compute_user_project_targets'
do
describe
'#compute_user_project_targets'
do
it
'returns the targets specified in the target definition'
do
it
'returns the targets specified in the target definition'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
link_with
=
[
'UserTarget'
]
target_definition
.
link_with
=
[
'UserTarget'
]
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
end
end
it
'raises if it is unable to find the targets specified by the target definition'
do
it
'raises if it is unable to find the targets specified by the target definition'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
link_with
=
[
'UserTarget'
]
target_definition
.
link_with
=
[
'UserTarget'
]
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find the targets/
e
.
message
.
should
.
match
/Unable to find the targets/
end
end
it
'returns the target with the same name of the target definition'
do
it
'returns the target with the same name of the target definition'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'UserTarget'
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'UserTarget'
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
end
end
it
'raises if the name of the target definition does not match any file'
do
it
'raises if the name of the target definition does not match any file'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'UserTarget'
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'UserTarget'
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find a target named/
e
.
message
.
should
.
match
/Unable to find a target named/
end
end
it
'returns the first target of the project if the target definition is named default'
do
it
'returns the first target of the project if the target definition is named default'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
target_definition
.
link_with_first_target
=
true
target_definition
.
link_with_first_target
=
true
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
=
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'FirstTarget'
]
targets
.
map
(
&
:name
).
should
==
[
'FirstTarget'
]
end
end
it
'raises if the default target definition cannot be linked because there are no user targets'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find a target/
end
it
'raises if the default target definition cannot be linked because there are no user targets'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
@analyzer
.
send
(
:compute_user_project_targets
,
target_definition
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find a target/
end
end
end
#--------------------------------------#
#--------------------------------------#
describe
'#compute_user_build_configurations'
do
describe
'#compute_user_build_configurations'
do
it
'returns the user build configurations of the user targets'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
configuration
=
user_project
.
new
(
Xcodeproj
::
Project
::
Object
::
XCBuildConfiguration
)
configuration
.
name
=
'AppStore'
target
.
build_configuration_list
.
build_configurations
<<
configuration
it
'returns the user build configurations of the user targets'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_targets
=
[
target
]
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
configuration
=
user_project
.
new
(
Xcodeproj
::
Project
::
Object
::
XCBuildConfiguration
)
configuration
.
name
=
'AppStore'
target
.
build_configuration_list
.
build_configurations
<<
configuration
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
configurations
=
@analyzer
.
send
(
:compute_user_build_configurations
,
target_definition
,
user_targets
)
user_targets
=
[
target
]
configurations
.
should
==
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
}
end
configurations
=
@analyzer
.
send
(
:compute_user_build_configurations
,
target_definition
,
user_targets
)
it
'returns the user build configurations specified in the target definition'
do
configurations
.
should
==
{
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
'Debug'
=>
:debug
,
target_definition
.
build_configurations
=
{
'AppStore'
=>
:release
}
'Release'
=>
:release
,
user_targets
=
[]
'AppStore'
=>
:release
,
}
end
it
'returns the user build configurations specified in the target definition'
do
configurations
=
@analyzer
.
send
(
:compute_user_build_configurations
,
target_definition
,
user_targets
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
configurations
.
should
==
{
'AppStore'
=>
:release
}
target_definition
.
build_configurations
=
{
'AppStore'
=>
:release
}
end
user_targets
=
[]
configurations
=
@analyzer
.
send
(
:compute_user_build_configurations
,
target_definition
,
user_targets
)
configurations
.
should
==
{
'AppStore'
=>
:release
}
end
end
end
#--------------------------------------#
#--------------------------------------#
describe
'#compute_archs_for_target_definition'
do
describe
'#compute_archs_for_target_definition'
do
it
'handles a single ARCH defined in a single user target'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
target
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
it
'handles a single ARCH defined in a single user target'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
user_targets
=
[
target
]
target
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
archs
.
should
==
'armv7'
user_targets
=
[
target
]
end
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
it
'handles a single ARCH defined in multiple user targets'
do
archs
.
should
==
'armv7'
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
end
targeta
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targeta
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
targetb
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targetb
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
targeta
,
targetb
]
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
archs
.
should
==
'armv7'
end
it
'handles an Array of ARCHs defined in a single user target'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
target
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 i386)
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
target
]
it
'handles a single ARCH defined in multiple user targets'
do
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
%w(armv7 i386)
.
each
{
|
a
|
archs
.
should
.
include
a
}
targeta
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
end
targeta
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
targetb
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
it
'handles an Array of ARCHs defined multiple user targets'
do
targetb
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
'armv7'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
targeta
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targeta
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 armv7s)
)
targetb
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targetb
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 i386)
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
targeta
,
targetb
]
user_targets
=
[
targeta
,
targetb
]
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
archs
.
should
==
'armv7'
%w(armv7 armv7s i386)
.
each
{
|
a
|
archs
.
should
.
include
a
}
end
end
end
it
'handles an Array of ARCHs defined in a single user target'
do
#--------------------------------------#
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
describe
'#compute_platform_for_target_definition'
do
target
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 i386)
)
it
'returns the platform specified in the target definition'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[]
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
it
'infers the platform from the user targets'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
target
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target
]
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
it
'uses the lowest deployment target of the user targets if inferring the platform'
do
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_targets
=
[
target
]
target1
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
configuration1
=
target1
.
build_configuration_list
.
build_configurations
.
first
target1
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target1
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
target2
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
%w(armv7 i386)
.
each
{
|
a
|
archs
.
should
.
include
a
}
target2
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target2
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'6.0'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target1
,
target2
]
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
it
'raises if the user targets have a different platform'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
target1
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
target1
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target1
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
target2
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
target2
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'macosx'
)
target2
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'10.6'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target1
,
target2
]
e
=
lambda
{
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Targets with different platforms/
end
end
end
it
'handles an Array of ARCHs defined multiple user targets'
do
#--------------------------------------#
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
targeta
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targeta
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 armv7s)
)
targetb
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
targetb
.
build_configuration_list
.
set_setting
(
'ARCHS'
,
%w(armv7 i386)
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
describe
'#sources'
do
target_definition
.
set_platform
(
:ios
,
'4.0'
)
describe
'when there are no explicit sources'
do
user_targets
=
[
targeta
,
targetb
]
it
'defaults to all sources'
do
@analyzer
.
send
(
:sources
).
map
(
&
:url
).
should
==
SourcesManager
.
all
.
map
(
&
:url
)
end
end
archs
=
@analyzer
.
send
(
:compute_archs_for_target_definition
,
target_definition
,
user_targets
)
describe
'when there are explicit sources'
do
%w(armv7 armv7s i386)
.
each
{
|
a
|
archs
.
should
.
include
a
}
it
'raises if no specs repo with that URL could be added'
do
podfile
=
Podfile
.
new
do
source
'not-a-git-repo'
end
@analyzer
.
instance_variable_set
(
:@podfile
,
podfile
)
should
.
raise
Informative
do
@analyzer
.
send
(
:sources
)
end
.
message
.
should
.
match
/Unable to add/
end
it
'fetches a specs repo that is specified by the podfile'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/artsy/Specs.git'
end
@analyzer
.
instance_variable_set
(
:@podfile
,
podfile
)
SourcesManager
.
expects
(
:find_or_create_source_with_url
).
once
@analyzer
.
send
(
:sources
)
end
end
end
end
end
end
end
#--------------------------------------#
describe
'Analysis, concerning naming'
do
before
do
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
end
describe
'#compute_platform_for_target_definition'
do
it
'raises when dependencies with the same name have different '
\
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/SEGModules.git'
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/Modules.git'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
it
'returns the platform specified in the target definition'
do
e
.
message
.
should
.
match
/different sources for `SEGModules`/
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/SEGModules.git`
\)
}
target_definition
.
set_platform
(
:ios
,
'4.0'
)
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/Modules.git`
\)
}
user_targets
=
[]
end
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
it
'raises when dependencies with the same root name have different '
\
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit/Core'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
:git
=>
'https://github.com/segiddins/RestKit.git'
end
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
it
'infers the platform from the user targets'
do
e
.
message
.
should
.
match
/different sources for `RestKit`/
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
.
message
.
should
.
match
%r{RestKit/Core
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/segiddins/RestKit.git`
\)
}
target
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
end
target
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
it
'raises when dependencies with the same name have different '
\
'external sources with one being nil'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
'~> 0.23.0'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
e
.
message
.
should
.
match
/different sources for `RestKit`/
user_targets
=
[
target
]
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
e
.
message
.
should
.
match
%r{RestKit
\(
~> 0.23.0
\)
}
end
end
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
describe
'using lockfile checkout options'
do
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
before
do
@podfile
=
Pod
::
Podfile
.
new
do
pod
'BananaLib'
,
:git
=>
'example.com'
end
end
@dependency
=
@podfile
.
dependencies
.
first
@lockfile_checkout_options
=
{
:git
=>
'example.com'
,
:commit
=>
'commit'
}
hash
=
{}
hash
[
'PODS'
]
=
[
'BananaLib (1.0.0)'
]
hash
[
'CHECKOUT OPTIONS'
]
=
{
'BananaLib'
=>
@lockfile_checkout_options
}
hash
[
'SPEC CHECKSUMS'
]
=
{}
hash
[
'COCOAPODS'
]
=
Pod
::
VERSION
@lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
@analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@podfile
,
@lockfile
)
end
it
'uses the lowest deployment target of the user targets if inferring the platform'
do
it
'returns that an update is required when there is no sandbox manifest'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
@analyzer
.
sandbox
.
stubs
(
:manifest
).
returns
(
nil
)
target1
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
@analyzer
.
should
.
send
(
:checkout_requires_update?
,
@dependency
)
configuration1
=
target1
.
build_configuration_list
.
build_configurations
.
first
end
target1
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target1
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
target2
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
before
do
target2
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
@sandbox_manifest
=
Pod
::
Lockfile
.
new
(
@lockfile
.
internal_data
.
deep_dup
)
target2
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'6.0'
)
@analyzer
.
sandbox
.
manifest
=
@sandbox_manifest
end
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
it
'returns whether or not an update is required'
do
user_targets
=
[
target1
,
target2
]
@analyzer
.
send
(
:checkout_requires_update?
,
@dependency
).
should
==
false
@sandbox_manifest
.
send
(
:checkout_options_data
).
delete
(
'BananaLib'
)
@analyzer
.
send
(
:checkout_requires_update?
,
@dependency
).
should
==
true
end
configurations
=
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
before
do
configurations
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
@analyzer
.
result
=
Installer
::
Analyzer
::
AnalysisResult
.
new
end
@analyzer
.
result
.
podfile_state
=
Installer
::
Analyzer
::
SpecsState
.
new
end
it
'raises if the user targets have a different platform'
do
it
'uses lockfile checkout options when no source exists in the sandbox'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
@analyzer
.
result
.
podfile_state
.
unchanged
<<
'BananaLib'
target1
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
@sandbox_manifest
.
send
(
:checkout_options_data
).
delete
(
'BananaLib'
)
target1
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'iphoneos'
)
target1
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'4.0'
)
target2
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
downloader
=
stub
(
'DownloaderSource'
)
target2
.
build_configuration_list
.
set_setting
(
'SDKROOT'
,
'macosx'
)
ExternalSources
.
stubs
(
:from_params
).
with
(
@lockfile_checkout_options
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
target2
.
build_configuration_list
.
set_setting
(
'IPHONEOS_DEPLOYMENT_TARGET'
,
'10.6'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
downloader
.
expects
(
:fetch
)
user_targets
=
[
target1
,
target2
]
@analyzer
.
send
(
:fetch_external_sources
)
e
=
lambda
{
@analyzer
.
send
(
:compute_platform_for_target_definition
,
target_definition
,
user_targets
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Targets with different platforms/
end
end
end
#--------------------------------------#
it
'uses lockfile checkout options when a different checkout exists in the sandbox'
do
@analyzer
.
result
.
podfile_state
.
unchanged
<<
'BananaLib'
@sandbox_manifest
.
send
(
:checkout_options_data
)[
'BananaLib'
]
=
@lockfile_checkout_options
.
merge
(
:commit
=>
'other commit'
)
describe
'#sources'
do
downloader
=
stub
(
'DownloaderSource'
)
describe
'when there are no explicit sources'
do
ExternalSources
.
stubs
(
:from_params
).
with
(
@lockfile_checkout_options
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
it
'defaults to all sources'
do
@analyzer
.
send
(
:sources
).
map
(
&
:url
).
should
==
SourcesManager
.
all
.
map
(
&
:url
)
end
end
describe
'when there are explicit sources'
do
downloader
.
expects
(
:fetch
)
it
'raises if no specs repo with that URL could be added'
do
@analyzer
.
send
(
:fetch_external_sources
)
podfile
=
Podfile
.
new
do
end
source
'not-a-git-repo'
end
@analyzer
.
instance_variable_set
(
:@podfile
,
podfile
)
should
.
raise
Informative
do
@analyzer
.
send
(
:sources
)
end
.
message
.
should
.
match
/Unable to add/
end
it
'fetches a specs repo that is specified by the podfile'
do
it
'ignores lockfile checkout options when the podfile state has changed'
do
podfile
=
Podfile
.
new
do
@analyzer
.
result
.
podfile_state
.
changed
<<
'BananaLib'
source
'https://github.com/artsy/Specs.git'
end
downloader
=
stub
(
'DownloaderSource'
)
@analyzer
.
instance_variable_set
(
:@podfile
,
podfile
)
ExternalSources
.
stubs
(
:from_params
).
with
(
@dependency
.
external_source
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
SourcesManager
.
expects
(
:find_or_create_source_with_url
).
once
@analyzer
.
send
(
:sources
)
downloader
.
expects
(
:fetch
)
end
@analyzer
.
send
(
:fetch_external_sources
)
end
end
it
'does not re-fetch the external source when the sandbox has the correct revision of the source'
do
@analyzer
.
result
.
podfile_state
.
unchanged
<<
'BananaLib'
@analyzer
.
expects
(
:fetch_external_source
).
never
@analyzer
.
send
(
:fetch_external_sources
)
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