Commit 2c8e43a3 authored by Samuel Giddins's avatar Samuel Giddins

[Init] Clean up target partitioning

parent 91eaa5f7
...@@ -63,17 +63,13 @@ module Pod ...@@ -63,17 +63,13 @@ module Pod
PLATFORM PLATFORM
# Split out the targets into app and test targets # Split out the targets into app and test targets
all_app_targets = project.native_targets.reject { |t| t.name =~ /tests?/i } test_targets, app_targets = project.native_targets.partition { |t| t.name =~ /test/i }
all_tests_targets = project.native_targets.select { |t| t.name =~ /tests?/i }
# Create an array of [app, (optional)test] target pairs app_targets.each do |app_target|
app_test_pairs = all_app_targets.map do |target| test_targets_for_app = test_targets.select do |target|
test = all_tests_targets.select { |t| t.name.start_with? target.name } target.name.downcase.start_with?(app_target.name.downcase)
[target, *test].compact
end end
podfile << target_module(app_target, test_targets_for_app)
app_test_pairs.each do |target_pair|
podfile << target_module(target_pair)
end end
podfile podfile
...@@ -85,12 +81,11 @@ module Pod ...@@ -85,12 +81,11 @@ module Pod
# #
# @return [String] the text for the target module # @return [String] the text for the target module
# #
def target_module(targets) def target_module(app, tests)
app = targets.first
target_module = "\ntarget '#{app.name.gsub(/'/, "\\\\\'")}' do\n" target_module = "\ntarget '#{app.name.gsub(/'/, "\\\\\'")}' do\n"
target_module << template_contents(config.default_podfile_path, " ", "Pods for #{app.name}\n") target_module << template_contents(config.default_podfile_path, " ", "Pods for #{app.name}\n")
targets[1..-1].each do |test| tests.each do |test|
target_module << "\n target '#{test.name.gsub(/'/, "\\\\\'")}' do\n" target_module << "\n target '#{test.name.gsub(/'/, "\\\\\'")}' do\n"
target_module << " inherit! :search_paths\n" target_module << " inherit! :search_paths\n"
target_module << template_contents(config.default_test_podfile_path, " ", "Pods for testing") target_module << template_contents(config.default_test_podfile_path, " ", "Pods for testing")
......
...@@ -96,8 +96,7 @@ module Pod ...@@ -96,8 +96,7 @@ module Pod
run_command('init') run_command('init')
podfile_text = File.read(temporary_directory + "Podfile") expected_podfile = <<-RUBY.strip_heredoc
podfile_exact = <<-PODFILE.strip_heredoc
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, '9.0' # platform :ios, '9.0'
# Uncomment this line if you're using Swift # Uncomment this line if you're using Swift
...@@ -117,9 +116,9 @@ module Pod ...@@ -117,9 +116,9 @@ module Pod
end end
end end
PODFILE RUBY
podfile_text.should == podfile_exact File.read('Podfile').should == expected_podfile
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