Commit ff995387 authored by Fabio Pelosin's avatar Fabio Pelosin

[#212] Check deployment targets at resolution time

parent b5828a9a
...@@ -27,12 +27,17 @@ module Pod ...@@ -27,12 +27,17 @@ module Pod
end end
end end
def support?(other)
return true if @symbolic_name.nil? || other.nil?
@symbolic_name == other.name && (deployment_target.nil? || other.deployment_target.nil? || deployment_target >= other.deployment_target)
end
def to_s def to_s
case @symbolic_name case @symbolic_name
when :ios when :ios
'iOS' + (deployment_target ? " #{deployment_target}" : '') 'iOS' + (deployment_target ? " #{deployment_target}" : '')
when :osx when :osx
'OS X' 'OS X' + (deployment_target ? " #{deployment_target}" : '')
else else
'iOS - OS X' 'iOS - OS X'
end end
......
...@@ -86,9 +86,9 @@ module Pod ...@@ -86,9 +86,9 @@ module Pod
end end
def validate_platform!(spec) def validate_platform!(spec)
unless spec.platform.nil? || spec.platform == @podfile.target_definitions[:default].platform plaform = @podfile.target_definitions[:default].platform
raise Informative, "The platform required by the Podfile (:#{@podfile.target_definitions[:default].platform}) " \ unless plaform.support?(spec.platform)
"does not match that of #{spec} (:#{spec.platform})" raise Informative, "The platform required by the Podfile `#{plaform}' does not match that of #{spec} `#{spec.platform}'"
end end
end end
end end
......
...@@ -26,6 +26,23 @@ describe Pod::Platform do ...@@ -26,6 +26,23 @@ describe Pod::Platform do
@platform.to_s.should == "iOS" @platform.to_s.should == "iOS"
Pod::Platform.new(:osx).to_s.should == 'OS X' Pod::Platform.new(:osx).to_s.should == 'OS X'
Pod::Platform.new(nil).to_s.should == "iOS - OS X" Pod::Platform.new(nil).to_s.should == "iOS - OS X"
Pod::Platform.new(:ios, { :deployment_target => '5.0.0' }).to_s.should == 'iOS 5.0.0'
Pod::Platform.new(:osx, { :deployment_target => '10.7' }).to_s.should == 'OS X 10.7'
end
it "correctly indicates if it supports another platfrom" do
ios4 = Pod::Platform.new(:ios, { :deployment_target => '4.0.0' })
ios5 = Pod::Platform.new(:ios, { :deployment_target => '5.0.0' })
ios5.should.support?(ios4)
ios4.should.not.support?(ios5)
osx6 = Pod::Platform.new(:osx, { :deployment_target => '10.6' })
osx7 = Pod::Platform.new(:osx, { :deployment_target => '10.7' })
osx7.should.support?(osx6)
osx6.should.not.support?(osx7)
both = Pod::Platform.new(nil)
both.should.support?(ios4)
both.should.support?(osx6)
both.should.support?(nil)
end end
it "uses it's name as it's symbold version" do it "uses it's name as it's symbold version" do
......
...@@ -59,6 +59,30 @@ describe "Pod::Resolver" do ...@@ -59,6 +59,30 @@ describe "Pod::Resolver" do
lambda { @resolver.resolve }.should.raise Pod::Informative lambda { @resolver.resolve }.should.raise Pod::Informative
end end
it "does not raise if all of the dependencies have a deployment target equal or lower of the root spec (Podfile)" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest')
@resolver.cached_sets['ASIHTTPRequest'] = set
def set.stub_platform=(platform); @stubbed_platform = platform; end
def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end
@podfile.platform :ios, { :deployment_target => "4.0.0" }
set.stub_platform = :ios, { :deployment_target => "4.0.0" }
lambda { @resolver.resolve }.should.not.raise
end
it "raises once any of the dependencies requires a higher deployment target of the root spec (Podfile)" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest')
@resolver.cached_sets['ASIHTTPRequest'] = set
def set.stub_platform=(platform); @stubbed_platform = platform; end
def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end
@podfile.platform :ios, { :deployment_target => "4.0.0" }
set.stub_platform = :ios, { :deployment_target => "5.0.0" }
lambda { @resolver.resolve }.should.raise Pod::Informative
end
it "resolves subspecs" do it "resolves subspecs" do
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :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