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

Make empty target definitions integrate properly

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