Commit 36f261ea authored by Sylvain Guillopé's avatar Sylvain Guillopé

[Analyzer] Use target_definition.empty? instead of dependencies

Use the more abstract `empty?` method. It excludes inherited
dependencies which is enough for this validation.
Add test where the target inherits the platform from its parent to
ensure the validation passes in this case as well.
parent 3819d532
...@@ -636,7 +636,7 @@ module Pod ...@@ -636,7 +636,7 @@ module Pod
def verify_platforms_specified! def verify_platforms_specified!
unless config.integrate_targets? unless config.integrate_targets?
podfile.target_definition_list.each do |target_definition| podfile.target_definition_list.each do |target_definition|
if target_definition.dependencies.size > 0 && target_definition.platform.nil? if !target_definition.empty? && target_definition.platform.nil?
raise Informative, 'It is necessary to specify the platform in the Podfile if not integrating.' raise Informative, 'It is necessary to specify the platform in the Podfile if not integrating.'
end end
end end
......
...@@ -221,7 +221,7 @@ module Pod ...@@ -221,7 +221,7 @@ module Pod
config.integrate_targets = false config.integrate_targets = false
end end
it 'does not require a platform for a podless target' do it 'does not require a platform for an empty target' do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
source SpecHelper.test_repo_url source SpecHelper.test_repo_url
xcodeproj 'SampleProject/SampleProject' xcodeproj 'SampleProject/SampleProject'
...@@ -235,7 +235,21 @@ module Pod ...@@ -235,7 +235,21 @@ module Pod
lambda { analyzer.analyze }.should.not.raise lambda { analyzer.analyze }.should.not.raise
end end
it 'raises if a target with pods does not specify a platform' do it 'does not raise if a target with dependencies inherits the platform from its parent' do
podfile = Pod::Podfile.new do
source SpecHelper.test_repo_url
xcodeproj 'SampleProject/SampleProject'
platform :osx
target 'TestRunner' do
pod 'monkey'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
lambda { analyzer.analyze }.should.not.raise
end
it 'raises if a target with dependencies does not have a platform' do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
source SpecHelper.test_repo_url source SpecHelper.test_repo_url
xcodeproj 'SampleProject/SampleProject' xcodeproj 'SampleProject/SampleProject'
......
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