Commit 17d5bc89 authored by Marius Rackwitz's avatar Marius Rackwitz

[Spec] Test frameworks for AggregateXCConfig

parent e4724166
......@@ -118,15 +118,32 @@ def fixture_file_accessor(name, platform = :ios)
Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
end
def fixture_pod_target(name, platform = :ios, target_definition = nil)
spec = fixture_spec(name)
target_definition ||= Pod::Podfile::TargetDefinition.new('Pods', nil)
def fixture_target_definition(podfile = nil, &block)
podfile ||= Pod::Podfile.new(&block)
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_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
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
......
......@@ -5,33 +5,30 @@ module Pod
module XCConfig
describe AggregateXCConfig do
def spec
fixture_spec('banana-lib/BananaLib.podspec')
end
before do
@spec = 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]
@spec = spec
@pod_target = fixture_pod_target(@spec)
@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
shared 'AggregateXCConfig' do
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
@podfile = Podfile.new
@target.target_definition.stubs(:podfile).returns(@podfile)
@xcconfig = @generator.generate
end
......@@ -39,7 +36,7 @@ module Pod
@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 'configures the project to load all members that implement Objective-c classes or categories' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-ObjC'
end
......@@ -59,16 +56,6 @@ module Pod
@xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end
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 'adds the COCOAPODS macro definition' do
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include 'COCOAPODS=1'
end
......@@ -77,20 +64,12 @@ module Pod
@xcconfig.to_hash['GCC_PREPROCESSOR_DEFINITIONS'].should.include '$(inherited)'
end
it 'links the pod targets with the aggregate integration library target' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include '-l"Pods-BananaLib"'
end
it 'does not links the pod targets with the aggregate integration library 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
it 'should configure OTHER_LIBTOOLFLAGS flags to include OTHER_LDFLAGS' do
@xcconfig.to_hash['OTHER_LIBTOOLFLAGS'].should == '$(OTHER_LDFLAGS)'
end
end
#-----------------------------------------------------------------------#
describe "if a pod target does not contain source files" do
......@@ -116,6 +95,67 @@ module Pod
#-----------------------------------------------------------------------#
describe 'with library' do
def spec
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
describe 'with framework' do
def spec
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)
......@@ -127,6 +167,8 @@ module Pod
end
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment