Commit 9b11b799 authored by Samuel Giddins's avatar Samuel Giddins

Move empty podfile validation to the podfile validator

parent 92a04dca
......@@ -160,6 +160,7 @@ module Pod
unless validator.valid?
raise Informative, validator.message
end
validator.warnings.uniq.each { |w| UI.warn(w) }
end
# @!group Analysis steps
......
......@@ -12,6 +12,11 @@ module Pod
#
attr_reader :errors
# @return [Array<String>] any warnings that have occured during the validation
#
attr_reader :warnings
# Initialize a new instance
# @param [Podfile] podfile
# The podfile to validate
......@@ -19,6 +24,7 @@ module Pod
def initialize(podfile)
@podfile = podfile
@errors = []
@warnings = []
@validated = false
end
......@@ -28,6 +34,7 @@ module Pod
def validate
validate_pod_directives
validate_no_abstract_only_pods!
validate_dependencies_are_present!
@validated = true
end
......@@ -55,6 +62,10 @@ module Pod
errors << error
end
def add_warning(warning)
warnings << warning
end
def validate_pod_directives
dependencies = podfile.target_definitions.flat_map do |_, target|
target.dependencies
......@@ -83,6 +94,23 @@ module Pod
end
end
# Warns the user if the podfile is empty.
#
# @note The workspace is created in any case and all the user projects
# are added to it, however the projects are not integrated as
# there is no way to discern between target definitions which are
# empty and target definitions which just serve the purpose to
# wrap other ones. This is not an issue because empty target
# definitions generate empty libraries.
#
# @return [void]
#
def validate_dependencies_are_present!
if podfile.target_definitions.values.all?(&:empty?)
add_warning 'The Podfile does not contain any dependencies.'
end
end
def validate_no_abstract_only_pods!
abstract_pods = ->(target_definition) do
if !target_definition.abstract? || !target_definition.children.empty?
......
......@@ -61,7 +61,6 @@ module Pod
def integrate!
create_workspace
integrate_user_targets
warn_about_empty_podfile
warn_about_xcconfig_overrides
save_projects
end
......@@ -152,23 +151,6 @@ module Pod
end
end
# Warns the user if the podfile is empty.
#
# @note The workspace is created in any case and all the user projects
# are added to it, however the projects are not integrated as
# there is no way to discern between target definitions which are
# empty and target definitions which just serve the purpose to
# wrap other ones. This is not an issue because empty target
# definitions generate empty libraries.
#
# @return [void]
#
def warn_about_empty_podfile
if podfile.target_definitions.values.all?(&:empty?)
UI.warn '[!] The Podfile does not contain any dependencies.'
end
end
IGNORED_KEYS = %w(CODE_SIGN_IDENTITY).freeze
INHERITED_FLAGS = %w($(inherited) ${inherited}).freeze
......
......@@ -62,5 +62,15 @@ module Pod
validator.errors[0].should.match /The dependency `JSONKit` specifies more than one/
end
end
it 'warns if the podfile does not contain any dependency' do
podfile = Pod::Podfile.new
validator = Installer::PodfileValidator.new(podfile)
validator.validate
validator.should.be.valid
validator.errors.should.be.empty
validator.warnings.should == ['The Podfile does not contain any dependencies.']
end
end
end
......@@ -51,13 +51,6 @@ module Pod
@integrator.integrate!
end
it 'warns if the podfile does not contain any dependency' do
@podfile = Pod::Podfile.new
@integrator.stubs(:podfile).returns(@podfile)
@integrator.integrate!
UI.warnings.should.include?('The Podfile does not contain any dependencies')
end
it 'deintegrates targets that are not associated with the podfile' do
additional_project = Xcodeproj::Project.new('Project.xcodeproj')
Deintegrator.any_instance.expects(:deintegrate_target).with additional_project.new_target(:application, 'Other App', :ios)
......
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