Commit 4730679b authored by Samuel Giddins's avatar Samuel Giddins

Partition test/non-test specs in the PodTarget

parent dc934649
......@@ -512,8 +512,9 @@ module Pod
hash[name] = values.sort_by { |pt| pt.specs.count }
end
pod_targets.each do |target|
dependencies = transitive_dependencies_for_specs(target.specs.reject(&:test_specification?).to_set, target.platform, all_resolver_specs.to_set).group_by(&:root)
test_dependencies = transitive_dependencies_for_specs(target.specs.select(&:test_specification?).to_set, target.platform, all_resolver_specs.to_set).group_by(&:root)
all_specs = all_resolver_specs.to_set
dependencies = transitive_dependencies_for_specs(target.non_test_specs.to_set, target.platform, all_specs).group_by(&:root)
test_dependencies = transitive_dependencies_for_specs(target.test_specs.to_set, target.platform, all_specs).group_by(&:root)
test_dependencies.delete_if { |k| dependencies.key? k }
target.dependent_targets = filter_dependencies(dependencies, pod_targets_by_name, target)
target.test_dependent_targets = filter_dependencies(test_dependencies, pod_targets_by_name, target)
......@@ -527,8 +528,9 @@ module Pod
end
pod_targets.each do |target|
dependencies = transitive_dependencies_for_specs(target.specs.reject(&:test_specification?).to_set, target.platform, specs.map(&:spec).to_set).group_by(&:root)
test_dependencies = transitive_dependencies_for_specs(target.specs.select(&:test_specification?).to_set, target.platform, specs.map(&:spec).to_set).group_by(&:root)
all_specs = specs.map(&:spec).to_set
dependencies = transitive_dependencies_for_specs(target.non_test_specs.to_set, target.platform, all_specs).group_by(&:root)
test_dependencies = transitive_dependencies_for_specs(target.test_specs.to_set, target.platform, all_specs).group_by(&:root)
test_dependencies.delete_if { |k| dependencies.key? k }
target.dependent_targets = pod_targets.reject { |t| dependencies[t.root_spec].nil? }
target.test_dependent_targets = pod_targets.reject { |t| test_dependencies[t.root_spec].nil? }
......
......@@ -29,7 +29,7 @@ module Pod
add_copy_resources_script_phase(native_target)
UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(test_specs), native_target)
end
specs = target.specs.reject(&:test_specification?)
specs = target.non_test_specs
UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(specs), target.native_target)
end
end
......
......@@ -49,7 +49,8 @@ module Pod
raise "Can't initialize a PodTarget with only abstract TargetDefinitions" if target_definitions.all?(&:abstract?)
raise "Can't initialize a PodTarget with an empty string scope suffix!" if scope_suffix == ''
super()
@specs = specs
@specs = specs.dup.freeze
@test_specs, @non_test_specs = @specs.partition(&:test_specification?)
@target_definitions = target_definitions
@sandbox = sandbox
@scope_suffix = scope_suffix
......@@ -216,20 +217,16 @@ module Pod
# @return [Boolean] Whether the target has any tests specifications.
#
def contains_test_specifications?
specs.any?(&:test_specification?)
!test_specs.empty?
end
# @return [Array<Specification>] All of the test specs within this target.
#
def test_specs
specs.select(&:test_specification?)
end
attr_reader :test_specs
# @return [Array<Specification>] All of the non test specs within this target.
#
def non_test_specs
specs.reject(&:test_specification?)
end
attr_reader :non_test_specs
# @return [Array<Symbol>] All of the test supported types within this target.
#
......
......@@ -188,9 +188,9 @@ module Pod
describe 'Private Helpers' do
describe '#file_accessors' do
it 'returns the file accessors' do
pod_target_1 = PodTarget.new([stub('Spec')], [fixture_target_definition], config.sandbox)
pod_target_1 = PodTarget.new([stub('Spec', :test_specification? => false)], [fixture_target_definition], config.sandbox)
pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
pod_target_2 = PodTarget.new([stub('Spec')], [fixture_target_definition], config.sandbox)
pod_target_2 = PodTarget.new([stub('Spec', :test_specification? => false)], [fixture_target_definition], config.sandbox)
pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
installer = FileReferencesInstaller.new(config.sandbox, [pod_target_1, pod_target_2], @project)
roots = installer.send(:file_accessors).map { |fa| fa.path_list.root }
......@@ -198,7 +198,7 @@ module Pod
end
it 'handles pods without file accessors' do
pod_target_1 = PodTarget.new([stub('Spec')], [fixture_target_definition], config.sandbox)
pod_target_1 = PodTarget.new([stub('Spec', :test_specification? => false)], [fixture_target_definition], config.sandbox)
pod_target_1.file_accessors = []
installer = FileReferencesInstaller.new(config.sandbox, [pod_target_1], @project)
installer.send(:file_accessors).should == []
......
......@@ -373,7 +373,7 @@ module Pod
@analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new
@spec = stub(:name => 'Spec')
@spec = stub(:name => 'Spec', :test_specification? => false)
@spec.stubs(:root => @spec)
@pod_targets = [PodTarget.new([@spec], [fixture_target_definition], config.sandbox)]
@installer.stubs(:analysis_result).returns(@analysis_result)
......
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