Exclude test resource and framework paths from aggregate targets

parent 38391fc7
......@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Justin Martin](https://github.com/justinseanmartin)
[#7013](https://github.com/CocoaPods/CocoaPods/pull/7013)
* Exclude test resource and framework paths from aggregate targets
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7000](https://github.com/CocoaPods/CocoaPods/pull/7000)
* Wrap platform warning message with quotes
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6968](https://github.com/CocoaPods/CocoaPods/pull/6968)
......
......@@ -194,7 +194,7 @@ module Pod
relevant_pod_targets = pod_targets.select do |pod_target|
pod_target.include_in_build_config?(target_definition, config)
end
framework_paths_by_config[config] = relevant_pod_targets.flat_map(&:framework_paths)
framework_paths_by_config[config] = relevant_pod_targets.flat_map { |pt| pt.framework_paths(false) }
end
framework_paths_by_config
end
......@@ -210,7 +210,7 @@ module Pod
user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
resources_by_config[config] = relevant_pod_targets.flat_map do |pod_target|
next [] unless pod_target.include_in_build_config?(target_definition, config)
(pod_target.resource_paths + [bridge_support_file].compact).uniq
(pod_target.resource_paths(false) + [bridge_support_file].compact).uniq
end
end
end
......
......@@ -197,13 +197,22 @@ module Pod
specs.select(&:test_specification?).map(&:test_type).uniq
end
# Returns the framework paths associated with this target. By default all paths include the framework paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include framework paths from test specifications or not.
#
# @return [Array<Hash{Symbol => [String]}>] The vendored and non vendored framework paths
# this target depends upon.
#
def framework_paths
@framework_paths ||= begin
def framework_paths(include_test_spec_paths = true)
@framework_paths ||= Hash.new do |h, key|
h[key] = begin
accessors = file_accessors
accessors = accessors.reject { |a| a.spec.test_specification? } unless include_test_spec_paths
frameworks = []
file_accessors.flat_map(&:vendored_dynamic_artifacts).map do |framework_path|
accessors.flat_map(&:vendored_dynamic_artifacts).map do |framework_path|
relative_path_to_sandbox = framework_path.relative_path_from(sandbox.root)
framework = { :name => framework_path.basename.to_s,
:input_path => "${PODS_ROOT}/#{relative_path_to_sandbox}",
......@@ -227,15 +236,26 @@ module Pod
frameworks
end
end
@framework_paths[include_test_spec_paths]
end
# Returns the resource paths associated with this target. By default all paths include the resource paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include resource paths from test specifications or not.
#
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
#
def resource_paths
@resource_paths ||= begin
resource_paths = file_accessors.flat_map do |accessor|
def resource_paths(include_test_spec_paths = true)
@resource_paths ||= Hash.new do |h, key|
h[key] = begin
accessors = file_accessors
accessors = accessors.reject { |a| a.spec.test_specification? } unless include_test_spec_paths
resource_paths = accessors.flat_map do |accessor|
accessor.resources.flat_map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" }
end
resource_bundles = file_accessors.flat_map do |accessor|
resource_bundles = accessors.flat_map do |accessor|
prefix = Generator::XCConfig::XCConfigHelper::CONFIGURATION_BUILD_DIR_VARIABLE
prefix = configuration_build_dir unless accessor.spec.test_specification?
accessor.resource_bundles.keys.map { |name| "#{prefix}/#{name.shellescape}.bundle" }
......@@ -243,13 +263,15 @@ module Pod
resource_paths + resource_bundles
end
end
@resource_paths[include_test_spec_paths]
end
# Returns the corresponding native target to use based on the provided specification.
# This is used to figure out whether to add a source file into the library native target or any of the
# test native targets.
#
# @param [Specification] spec
# The specifcation to base from in order to find the native target.
# The specification to base from in order to find the native target.
#
# @return [PBXNativeTarget] the native target to use or `nil` if none is found.
#
......
......@@ -375,6 +375,69 @@ module Pod
@test_pod_target.stubs(:file_accessors).returns([fa])
@test_pod_target.resource_paths.should == ['$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle']
end
it 'includes framework paths from test specifications' do
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:vendored_dynamic_artifacts).returns([config.sandbox.root + Pathname.new('Vendored/Vendored.framework')])
fa.stubs(:spec).returns(stub(:test_specification? => false))
test_fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
test_fa.stubs(:vendored_dynamic_artifacts).returns([config.sandbox.root + Pathname.new('Vendored/TestVendored.framework')])
test_fa.stubs(:spec).returns(stub(:test_specification? => true))
@test_pod_target.stubs(:file_accessors).returns([fa, test_fa])
@test_pod_target.stubs(:should_build?).returns(true)
@test_pod_target.framework_paths.should == [
{ :name => 'Vendored.framework',
:input_path => '${PODS_ROOT}/Vendored/Vendored.framework',
:output_path => '${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework' },
{ :name => 'TestVendored.framework',
:input_path => '${PODS_ROOT}/Vendored/TestVendored.framework',
:output_path => '${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TestVendored.framework' },
]
end
it 'excludes framework paths from test specifications when not requested' do
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:vendored_dynamic_artifacts).returns([config.sandbox.root + Pathname.new('Vendored/Vendored.framework')])
fa.stubs(:spec).returns(stub(:test_specification? => false))
test_fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
test_fa.stubs(:vendored_dynamic_artifacts).returns([config.sandbox.root + Pathname.new('Vendored/TestVendored.framework')])
test_fa.stubs(:spec).returns(stub(:test_specification? => true))
@test_pod_target.stubs(:file_accessors).returns([fa, test_fa])
@test_pod_target.stubs(:should_build?).returns(true)
@test_pod_target.framework_paths(false).should == [
{ :name => 'Vendored.framework',
:input_path => '${PODS_ROOT}/Vendored/Vendored.framework',
:output_path => '${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework' },
]
end
it 'includes resource paths from test specifications' do
config.sandbox.stubs(:project => stub(:path => Pathname.new('ProjectPath')))
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:resource_bundles).returns({})
fa.stubs(:resources).returns([Pathname.new('Model.xcdatamodeld')])
fa.stubs(:spec).returns(stub(:test_specification? => false))
test_fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
test_fa.stubs(:resource_bundles).returns({})
test_fa.stubs(:resources).returns([Pathname.new('TestModel.xcdatamodeld')])
test_fa.stubs(:spec).returns(stub(:test_specification? => true))
@test_pod_target.stubs(:file_accessors).returns([fa, test_fa])
@test_pod_target.resource_paths.should == ['${PODS_ROOT}/Model.xcdatamodeld', '${PODS_ROOT}/TestModel.xcdatamodeld']
end
it 'excludes resource paths from test specifications when not requested' do
config.sandbox.stubs(:project => stub(:path => Pathname.new('ProjectPath')))
fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
fa.stubs(:resource_bundles).returns({})
fa.stubs(:resources).returns([Pathname.new('Model.xcdatamodeld')])
fa.stubs(:spec).returns(stub(:test_specification? => false))
test_fa = Sandbox::FileAccessor.new(nil, @test_pod_target)
test_fa.stubs(:resource_bundles).returns({})
test_fa.stubs(:resources).returns([Pathname.new('TestModel.xcdatamodeld')])
test_fa.stubs(:spec).returns(stub(:test_specification? => true))
@test_pod_target.stubs(:file_accessors).returns([fa, test_fa])
@test_pod_target.resource_paths(false).should == ['${PODS_ROOT}/Model.xcdatamodeld']
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