Commit 26641970 authored by Eloy Duran's avatar Eloy Duran

Check if dependencies match the platform specified in the Podfile.

parent 0c8d53a4
...@@ -12,13 +12,26 @@ module Pod ...@@ -12,13 +12,26 @@ module Pod
def find_dependency_sets(specification) def find_dependency_sets(specification)
specification.dependencies.each do |dependency| specification.dependencies.each do |dependency|
set = Source.search(dependency) set = find_dependency_set(dependency)
set.required_by(specification) set.required_by(specification)
unless @sets.include?(set) unless @sets.include?(set)
validate_platform!(set)
@sets << set @sets << set
find_dependency_sets(set.specification) find_dependency_sets(set.specification)
end end
end end
end end
def find_dependency_set(dependency)
Source.search(dependency)
end
def validate_platform!(set)
spec = set.specification
unless spec.any_platform? || spec.platform == @specification.platform
raise Informative, "The platform required by the Podfile (:#{@specification.platform}) " \
"does not match that of #{spec} (:#{spec.platform})"
end
end
end end
end end
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
class StubbedSet < Pod::Specification::Set
attr_accessor :stub_platform
def specification
spec = super
spec.platform = @stub_platform
spec
end
end
class StubbedResolver < Pod::Resolver
attr_accessor :stub_platform
def find_dependency_set(dependency)
set = StubbedSet.new(super.pod_dir)
set.stub_platform = @stub_platform
set
end
end
describe "Pod::Resolver" do describe "Pod::Resolver" do
before do before do
fixture('spec-repos/master') # ensure the archive is unpacked fixture('spec-repos/master') # ensure the archive is unpacked
...@@ -18,5 +38,32 @@ describe "Pod::Resolver" do ...@@ -18,5 +38,32 @@ describe "Pod::Resolver" do
resolver = Pod::Resolver.new(Pod::Spec.new { |s| s.dependency 'ASIWebPageRequest' }) resolver = Pod::Resolver.new(Pod::Spec.new { |s| s.dependency 'ASIWebPageRequest' })
resolver.resolve.sort_by(&:name).should == sets.sort_by(&:name) resolver.resolve.sort_by(&:name).should == sets.sort_by(&:name)
end end
it "does not raise if all dependencies match the platform of the root spec (Podfile)" do
spec = Pod::Spec.new { |s| s.dependency 'ASIWebPageRequest' }
resolver = Pod::Resolver.new(spec)
spec.platform = :ios
lambda { resolver.resolve }.should.not.raise
spec.platform = :osx
lambda { resolver.resolve }.should.not.raise
end
it "raises once any of the dependencies does not match the platform of the root spec (Podfile)" do
spec = Pod::Spec.new { |s| s.dependency 'ASIWebPageRequest' }
resolver = StubbedResolver.new(spec)
spec.platform = :ios
resolver.stub_platform = :ios
lambda { resolver.resolve }.should.not.raise
resolver.stub_platform = :osx
lambda { resolver.resolve }.should.raise Pod::Informative
spec.platform = :osx
resolver.stub_platform = :osx
lambda { resolver.resolve }.should.not.raise
resolver.stub_platform = :ios
lambda { resolver.resolve }.should.raise Pod::Informative
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