Commit c7c2440f authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Resolver] Test platform resolution

parent cd57041f
......@@ -55,7 +55,7 @@ module Pod
def resolve
dependencies = podfile.target_definition_list.flat_map do |target|
target.dependencies.each do |dep|
@platforms_by_dependency[dep] << target.platform
@platforms_by_dependency[dep].<<(target.platform).uniq!
end
end
@cached_sets = {}
......@@ -416,9 +416,9 @@ module Pod
pred + pred.map(&all_predecessors).reduce(Set.new, &:&) << vertex
end
vertex = dependency_graph.vertex_named(dependency.name)
predecessors = all_predecessors[vertex]
platforms_to_satisfy = predecessors.map(&:requirements).flat_map { |r| @platforms_by_dependency[r] }
platforms_to_satisfy.all? { |pts| spec.available_platforms.any? { |p| pts.supports?(p) } }
predecessors = all_predecessors[vertex].reject { |v| v.explicit_requirements.empty? }
platforms_to_satisfy = predecessors.flat_map(&:explicit_requirements).flat_map { |r| @platforms_by_dependency[r] }
platforms_to_satisfy.all? { |pts| spec.available_platforms.select { |p| p.name == pts.name }.all? { |p| pts.supports?(p) } }
end
# Returns the target-appropriate nodes that are `successors` of `node`,
......
......@@ -328,12 +328,6 @@ module Pod
]
end
it 'warns once any of the dependencies does not match the platform of its podfile target' do
Specification.any_instance.stubs(:available_platforms).returns([Platform.new(:ios, '999')])
@analyzer.analyze
UI.warnings.should.match(/platform .* may not be compatible/)
end
xit 'removes the specifications of the changed pods to prevent confusion in the resolution process' do
@analyzer.allow_pre_downloads = true
podspec = @analyzer.sandbox.root + 'Local Podspecs/JSONKit.podspec'
......
......@@ -180,6 +180,17 @@ module Pod
end.message.should.match /platform .* not compatible/
end
it 'selects only platform-compatible versions' do
@podfile = Podfile.new do
platform :osx, '10.7'
pod 'AFNetworking' # the most recent version requires 10.8
end
@resolver.stubs(:podfile).returns(@podfile)
@resolver.resolve.values.flatten.map(&:to_s).sort.should == [
'AFNetworking (1.3.4)'
]
end
it 'raises if unable to find a specification' do
Specification.any_instance.stubs(:all_dependencies).returns([Dependency.new('Windows')])
message = should.raise Informative do
......@@ -340,7 +351,7 @@ module Pod
it 'raises if it finds two conflicting dependencies' do
podfile = Podfile.new do
platform :ios
platform :ios, '8.0'
pod 'RestKit', '0.23.3' # dependends on AFNetworking ~> 1.3.0
pod 'AFNetworking', '> 2'
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