Commit 92a04dca authored by Samuel Giddins's avatar Samuel Giddins

Make empty target definitions integrate properly

parent 7a1b2ad6
......@@ -629,13 +629,13 @@ module Pod
def install_libraries
UI.message '- Installing targets' do
pod_targets.sort_by(&:name).each do |pod_target|
next if pod_target.target_definitions.flat_map(&:dependencies).empty?
next if pod_target.target_definitions.all?(&:abstract?)
target_installer = PodTargetInstaller.new(sandbox, pod_target)
target_installer.install!
end
aggregate_targets.sort_by(&:name).each do |target|
next if target.target_definition.dependencies.empty?
next if target.target_definition.abstract?
target_installer = AggregateTargetInstaller.new(sandbox, target)
target_installer.install!
end
......
......@@ -234,7 +234,7 @@ module Pod
end
def targets_to_integrate
targets.reject { |target| target.target_definition.empty? }
targets.reject { |target| target.target_definition.abstract? }
end
# Prints a warning informing the user that a build configuration of
......
......@@ -9,18 +9,23 @@ module Pod
@podfile = Podfile.new do
platform :ios
xcodeproj sample_project_path
pod 'JSONKit'
target :empty do
target 'SampleProject' do
pod 'JSONKit'
target :empty do
end
end
end
config.sandbox.project = Project.new(config.sandbox.project_path)
config.sandbox.project.save
@target = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@target = AggregateTarget.new(@podfile.target_definitions['SampleProject'], config.sandbox)
@target.client_root = sample_project_path.dirname
@target.user_project = Xcodeproj::Project.open(@sample_project_path)
@target.user_target_uuids = ['A346496C14F9BE9A0080D870']
empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox)
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target, empty_library])
@empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox)
@empty_library.client_root = sample_project_path.dirname
@empty_library.user_project = @target.user_project
@empty_library.user_target_uuids = ['C0C495321B9E5C47004F9854']
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target, @empty_library])
end
#-----------------------------------------------------------------------#
......@@ -42,12 +47,13 @@ module Pod
end
it 'integrates the user targets' do
UserProjectIntegrator::TargetIntegrator.any_instance.expects(:integrate!)
UserProjectIntegrator::TargetIntegrator.any_instance.expects(:integrate!).twice
@integrator.integrate!
end
it 'warns if the podfile does not contain any dependency' do
Podfile::TargetDefinition.any_instance.stubs(:empty?).returns(true)
@podfile = Pod::Podfile.new
@integrator.stubs(:podfile).returns(@podfile)
@integrator.integrate!
UI.warnings.should.include?('The Podfile does not contain any dependencies')
end
......@@ -57,7 +63,7 @@ module Pod
Deintegrator.any_instance.expects(:deintegrate_target).with additional_project.new_target(:application, 'Other App', :ios)
user_project = @target.user_project
user_project.native_targets.each do |target|
next if target.name == 'SampleProject'
next if %w(SampleProject SampleProjectTests).include?(target.name)
Deintegrator.any_instance.expects(:deintegrate_target).with(target)
end
@integrator.stubs(:user_projects).returns([additional_project, user_project])
......@@ -201,9 +207,15 @@ module Pod
@integrator.send(:user_project_paths).should == [@sample_project_path]
end
it 'skips libraries with empty target definitions' do
@integrator.targets.map(&:name).should == ['Pods', 'Pods-empty']
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
it 'does not skip libraries with empty target definitions' do
@integrator.targets.map(&:name).should == ['Pods-SampleProject', 'Pods-SampleProject-empty']
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods-SampleProject', 'Pods-SampleProject-empty']
end
it 'does skip libraries with only abstract target definitions' do
@integrator.targets.map(&:name).should == ['Pods-SampleProject', 'Pods-SampleProject-empty']
@podfile.target_definition_list.each { |td| td.abstract = true }
@integrator.send(:targets_to_integrate).map(&:name).should == []
end
it 'skips saving projects that are not dirtied (but touches them instead)' do
......
......@@ -646,13 +646,13 @@ module Pod
@installer.send(:install_libraries)
end
it 'skips empty pod targets' do
it 'does not skip empty pod targets' do
spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil)
pod_target = PodTarget.new([spec], [target_definition], config.sandbox)
@installer.stubs(:aggregate_targets).returns([])
@installer.stubs(:pod_targets).returns([pod_target])
Installer::PodTargetInstaller.any_instance.expects(:install!).never
Installer::PodTargetInstaller.any_instance.expects(:install!).once
@installer.send(:install_libraries)
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