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
17d5bc89
Commit
17d5bc89
authored
Dec 16, 2014
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Spec] Test frameworks for AggregateXCConfig
parent
e4724166
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
78 deletions
+137
-78
spec_helper.rb
spec/spec_helper.rb
+21
-4
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+116
-74
No files found.
spec/spec_helper.rb
View file @
17d5bc89
...
@@ -118,15 +118,32 @@ def fixture_file_accessor(name, platform = :ios)
...
@@ -118,15 +118,32 @@ def fixture_file_accessor(name, platform = :ios)
Pod
::
Sandbox
::
FileAccessor
.
new
(
path_list
,
spec
.
consumer
(
platform
))
Pod
::
Sandbox
::
FileAccessor
.
new
(
path_list
,
spec
.
consumer
(
platform
))
end
end
def
fixture_pod_target
(
name
,
platform
=
:ios
,
target_definition
=
nil
)
def
fixture_target_definition
(
podfile
=
nil
,
&
block
)
spec
=
fixture_spec
(
name
)
podfile
||=
Pod
::
Podfile
.
new
(
&
block
)
target_definition
||=
Pod
::
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
Pod
::
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
podfile
)
end
def
fixture_pod_target
(
spec_or_name
,
platform
=
:ios
,
target_definition
=
nil
)
spec
=
spec_or_name
.
is_a?
(
Pod
::
Specification
)
?
spec_or_name
:
fixture_spec
(
spec_or_name
)
target_definition
||=
fixture_target_definition
target_definition
.
store_pod
(
spec
.
name
)
Pod
::
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
).
tap
do
|
pod_target
|
Pod
::
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
).
tap
do
|
pod_target
|
pod_target
.
stubs
(
:platform
).
returns
(
platform
)
pod_target
.
stubs
(
:platform
).
returns
(
platform
)
pod_target
.
file_accessors
<<
fixture_file_accessor
(
name
,
platform
)
pod_target
.
file_accessors
<<
fixture_file_accessor
(
spec
.
defined_in_file
,
platform
)
consumer
=
spec
.
consumer
(
platform
)
pod_target
.
spec_consumers
<<
consumer
end
end
end
end
def
fixture_aggregate_target
(
pod_targets
=
[],
platform
=
:ios
,
target_definition
=
nil
)
target_definition
||=
pod_targets
.
map
(
&
:target_definition
).
first
||
fixture_target_definition
target
=
Pod
::
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
target
.
client_root
=
config
.
sandbox
.
root
.
dirname
target
.
stubs
(
:platform
).
returns
(
platform
)
target
.
pod_targets
=
pod_targets
target
end
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
SpecHelper
::
Fixture
.
fixture
(
'banana-lib'
)
# ensure it exists
SpecHelper
::
Fixture
.
fixture
(
'banana-lib'
)
# ensure it exists
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
17d5bc89
...
@@ -5,90 +5,69 @@ module Pod
...
@@ -5,90 +5,69 @@ module Pod
module
XCConfig
module
XCConfig
describe
AggregateXCConfig
do
describe
AggregateXCConfig
do
before
do
def
spec
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@consumer
=
@spec
.
consumer
(
:ios
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
target_definition
.
store_pod
(
'BananaLib'
)
target_definition
.
whitelist_pod_for_configuration
(
'BananaLib'
,
'Release'
)
@target
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
@target
.
client_root
=
config
.
sandbox
.
root
.
dirname
@target
.
stubs
(
:platform
).
returns
(
:ios
)
@pod_target
=
PodTarget
.
new
([
@spec
],
target_definition
,
config
.
sandbox
)
@pod_target
.
stubs
(
:platform
).
returns
(
:ios
)
@pod_target
.
stubs
(
:spec_consumers
).
returns
([
@consumer
])
file_accessor
=
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)
@pod_target
.
stubs
(
:file_accessors
).
returns
([
file_accessor
])
@target
.
pod_targets
=
[
@pod_target
]
@generator
=
AggregateXCConfig
.
new
(
@target
,
'Release'
)
end
end
it
'returns the path of the pods root relative to the user project'
do
@generator
.
target
.
relative_pods_root
.
should
==
'${SRCROOT}/Pods'
end
#-----------------------------------------------------------------------#
before
do
before
do
@podfile
=
Podfile
.
new
@spec
=
spec
@target
.
target_definition
.
stubs
(
:podfile
).
returns
(
@podfile
)
@pod_target
=
fixture_pod_target
(
@spec
)
@xcconfig
=
@generator
.
generate
@consumer
=
@pod_target
.
spec_consumers
.
last
@target
=
fixture_aggregate_target
([
@pod_target
])
@target
.
target_definition
.
should
==
@pod_target
.
target_definition
@target
.
target_definition
.
whitelist_pod_for_configuration
(
@spec
.
name
,
'Release'
)
@podfile
=
@target
.
target_definition
.
podfile
@generator
=
AggregateXCConfig
.
new
(
@target
,
'Release'
)
end
end
it
'generates the xcconfig'
do
shared
'AggregateXCConfig'
do
@xcconfig
.
class
.
should
==
Xcodeproj
::
Config
end
it
'configures the project to load all members that implement Objective-c classes or categories from the static library
'
do
it
'returns the path of the pods root relative to the user project
'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-ObjC
'
@generator
.
target
.
relative_pods_root
.
should
==
'${SRCROOT}/Pods
'
end
end
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it'
do
#--------------------------------------------------------------------#
@consumer
.
stubs
(
:requires_arc?
).
returns
(
true
)
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
not
.
include
(
'-fobjc-arc'
)
end
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it'
do
before
do
@podfile
.
stubs
(
:set_arc_compatibility_flag?
).
returns
(
true
)
@xcconfig
=
@generator
.
generate
@consumer
.
stubs
(
:requires_arc?
).
returns
(
true
)
end
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
' '
).
should
.
include
(
'-fobjc-arc'
)
end
it
'sets the PODS_ROOT build variable
'
do
it
'generates the xcconfig
'
do
@xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}/Pods'
@xcconfig
.
class
.
should
==
Xcodeproj
::
Config
end
end
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as header search paths'
do
it
'configures the project to load all members that implement Objective-c classes or categories'
do
expected
=
"
\"
#{
config
.
sandbox
.
public_headers
.
search_paths
(
:ios
).
join
(
'" "'
)
}
\"
"
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-ObjC'
@xcconfig
.
to_hash
[
'HEADER_SEARCH_PATHS'
].
should
==
expected
end
end
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers
'
do
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it
'
do
expected
=
"$(inherited) -isystem
\"
#{
config
.
sandbox
.
public_headers
.
search_paths
(
:ios
).
join
(
'" -isystem "'
)
}
\"
"
@consumer
.
stubs
(
:requires_arc?
).
returns
(
true
)
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
not
.
include
(
'-fobjc-arc'
)
end
end
it
'adds the COCOAPODS macro definition'
do
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc and the podfile explicitly requires it'
do
@xcconfig
.
to_hash
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
'COCOAPODS=1'
@podfile
.
stubs
(
:set_arc_compatibility_flag?
).
returns
(
true
)
end
@consumer
.
stubs
(
:requires_arc?
).
returns
(
true
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
' '
).
should
.
include
(
'-fobjc-arc'
)
end
it
'inherits the parent GCC_PREPROCESSOR_DEFINITIONS valu
e'
do
it
'sets the PODS_ROOT build variabl
e'
do
@xcconfig
.
to_hash
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
'$(inherited)
'
@xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}/Pods
'
end
end
it
'links the pod targets with the aggregate integration library target
'
do
it
'adds the COCOAPODS macro definition
'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-l"Pods-BananaLib"
'
@xcconfig
.
to_hash
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
'COCOAPODS=1
'
end
end
it
'does not links the pod targets with the aggregate integration library target for non-whitelisted configuration'
do
it
'inherits the parent GCC_PREPROCESSOR_DEFINITIONS value'
do
@generator
=
AggregateXCConfig
.
new
(
@target
,
'Debug'
)
@xcconfig
.
to_hash
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
'$(inherited)'
@xcconfig
=
@generator
.
generate
end
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
not
.
include
'-l"Pods-BananaLib"'
end
it
'should configure OTHER_LIBTOOLFLAGS flags to include OTHER_LDFLAGS'
do
@xcconfig
.
to_hash
[
'OTHER_LIBTOOLFLAGS'
].
should
==
'$(OTHER_LDFLAGS)'
end
it
'should configure OTHER_LIBTOOLFLAGS flags to include OTHER_LDFLAGS'
do
@xcconfig
.
to_hash
[
'OTHER_LIBTOOLFLAGS'
].
should
==
'$(OTHER_LDFLAGS)'
end
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
...
@@ -116,14 +95,77 @@ module Pod
...
@@ -116,14 +95,77 @@ module Pod
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
before
do
describe
'with library'
do
@path
=
temporary_directory
+
'sample.xcconfig'
def
spec
@generator
.
save_as
(
@path
)
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
end
behaves_like
'AggregateXCConfig'
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as header search paths'
do
expected
=
"
\"
#{
config
.
sandbox
.
public_headers
.
search_paths
(
:ios
).
join
(
'" "'
)
}
\"
"
@xcconfig
.
to_hash
[
'HEADER_SEARCH_PATHS'
].
should
==
expected
end
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers'
do
expected
=
"$(inherited) -isystem
\"
#{
config
.
sandbox
.
public_headers
.
search_paths
(
:ios
).
join
(
'" -isystem "'
)
}
\"
"
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
it
'links the pod targets with the aggregate target'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-l"Pods-BananaLib"'
end
it
'does not links the pod targets with the aggregate target for non-whitelisted configuration'
do
@generator
=
AggregateXCConfig
.
new
(
@target
,
'Debug'
)
@xcconfig
=
@generator
.
generate
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
not
.
include
'-l"Pods-BananaLib"'
end
end
end
it
'saves the xcconfig'
do
describe
'with framework'
do
generated
=
Xcodeproj
::
Config
.
new
(
@path
)
def
spec
generated
.
class
.
should
==
Xcodeproj
::
Config
fixture_spec
(
'orange-framework/OrangeFramework.podspec'
)
end
behaves_like
'AggregateXCConfig'
it
'sets the PODS_FRAMEWORK_BUILD_PATH build variable'
do
@xcconfig
.
to_hash
[
'PODS_FRAMEWORK_BUILD_PATH'
].
should
==
'$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods'
end
it
'adds the framework build path to the xcconfig, with quotes, as framework search paths'
do
@xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
"
\"
$PODS_FRAMEWORK_BUILD_PATH
\"
"
end
it
'adds the framework header paths to the xcconfig, with quotes, as local headers'
do
expected
=
"$(inherited) -iquote
\"
$PODS_FRAMEWORK_BUILD_PATH/OrangeFramework.framework/Headers
\"
"
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
it
'links the pod targets with the aggregate target'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-framework "OrangeFramework"'
end
it
'adds the COCOAPODS macro definition'
do
@xcconfig
.
to_hash
[
'OTHER_SWIFT_FLAGS'
].
should
.
include
'-D COCOAPODS'
end
end
#-----------------------------------------------------------------------#
describe
"serializing and deserializing"
do
before
do
@path
=
temporary_directory
+
'sample.xcconfig'
@generator
.
save_as
(
@path
)
end
it
'saves the xcconfig'
do
generated
=
Xcodeproj
::
Config
.
new
(
@path
)
generated
.
class
.
should
==
Xcodeproj
::
Config
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