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

[Resolver] Test platform resolution

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