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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
152 additions
and
69 deletions
+152
-69
sandbox.rb
lib/cocoapods/sandbox.rb
+4
-0
spec_helper.rb
spec/spec_helper.rb
+2
-0
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+146
-69
No files found.
lib/cocoapods/sandbox.rb
View file @
266f42e1
...
@@ -64,9 +64,13 @@ module Pod
...
@@ -64,9 +64,13 @@ 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
@manifest
||=
begin
Lockfile
.
from_file
(
manifest_path
)
if
manifest_path
.
exist?
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
module
Pod
describe
Installer
::
Analyzer
do
describe
'Analysis'
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
,
'6.0'
platform
:ios
,
'6.0'
xcodeproj
'SampleProject/SampleProject'
xcodeproj
'SampleProject/SampleProject'
...
@@ -17,23 +21,12 @@ def create_analyzer
...
@@ -17,23 +21,12 @@ def create_analyzer
hash
[
'DEPENDENCIES'
]
=
%w(JSONKit NUI SVPullToRefresh)
hash
[
'DEPENDENCIES'
]
=
%w(JSONKit NUI SVPullToRefresh)
hash
[
'SPEC CHECKSUMS'
]
=
{}
hash
[
'SPEC CHECKSUMS'
]
=
{}
hash
[
'COCOAPODS'
]
=
Pod
::
VERSION
hash
[
'COCOAPODS'
]
=
Pod
::
VERSION
lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
@
lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@podfile
,
lockfile
)
@analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@podfile
,
@lockfile
)
end
#-----------------------------------------------------------------------------#
module
Pod
describe
Installer
::
Analyzer
do
before
do
@analyzer
=
create_analyzer
end
end
describe
'Analysis'
do
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
end
end
...
@@ -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,8 +253,6 @@ module Pod
...
@@ -311,8 +253,6 @@ 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
...
@@ -609,4 +549,141 @@ module Pod
...
@@ -609,4 +549,141 @@ module Pod
end
end
end
end
end
end
describe
'Analysis, concerning naming'
do
before
do
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
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
end
describe
'using lockfile checkout options'
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
pod
'BananaLib'
,
:git
=>
'example.com'
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
'returns that an update is required when there is no sandbox manifest'
do
@analyzer
.
sandbox
.
stubs
(
:manifest
).
returns
(
nil
)
@analyzer
.
should
.
send
(
:checkout_requires_update?
,
@dependency
)
end
before
do
@sandbox_manifest
=
Pod
::
Lockfile
.
new
(
@lockfile
.
internal_data
.
deep_dup
)
@analyzer
.
sandbox
.
manifest
=
@sandbox_manifest
end
it
'returns whether or not an update is required'
do
@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
before
do
@analyzer
.
result
=
Installer
::
Analyzer
::
AnalysisResult
.
new
@analyzer
.
result
.
podfile_state
=
Installer
::
Analyzer
::
SpecsState
.
new
end
it
'uses lockfile checkout options when no source exists in the sandbox'
do
@analyzer
.
result
.
podfile_state
.
unchanged
<<
'BananaLib'
@sandbox_manifest
.
send
(
:checkout_options_data
).
delete
(
'BananaLib'
)
downloader
=
stub
(
'DownloaderSource'
)
ExternalSources
.
stubs
(
:from_params
).
with
(
@lockfile_checkout_options
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
downloader
.
expects
(
:fetch
)
@analyzer
.
send
(
:fetch_external_sources
)
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'
)
downloader
=
stub
(
'DownloaderSource'
)
ExternalSources
.
stubs
(
:from_params
).
with
(
@lockfile_checkout_options
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
downloader
.
expects
(
:fetch
)
@analyzer
.
send
(
:fetch_external_sources
)
end
it
'ignores lockfile checkout options when the podfile state has changed'
do
@analyzer
.
result
.
podfile_state
.
changed
<<
'BananaLib'
downloader
=
stub
(
'DownloaderSource'
)
ExternalSources
.
stubs
(
:from_params
).
with
(
@dependency
.
external_source
,
@dependency
,
@podfile
.
defined_in_file
).
returns
(
downloader
)
downloader
.
expects
(
:fetch
)
@analyzer
.
send
(
:fetch_external_sources
)
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
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