Commit e8033ca0 authored by Thomas Visser's avatar Thomas Visser Committed by Samuel E. Giddins

[Resolver] Added tests, notice if the required version exists in multiple…

[Resolver] Added tests, notice if the required version exists in multiple sources (CocoaPods/CocoaPods#2556)
parent c560e1be
...@@ -149,6 +149,13 @@ module Pod ...@@ -149,6 +149,13 @@ module Pod
set = find_cached_set(dependency, dependent_spec) set = find_cached_set(dependency, dependent_spec)
set.required_by(dependency, dependent_spec.to_s) set.required_by(dependency, dependent_spec.to_s)
unless set.sources.empty?
unless set.specification_paths_for_version(set.required_version).length == 1
UI.message("Found multiple specifications for #{dependency}:" \
"#{set.specification_paths_for_version(set.required_version).join(', ')}")
end
end
unless @loaded_specs.include?(dependency.name) unless @loaded_specs.include?(dependency.name)
spec = set.specification.subspec_by_name(dependency.name) spec = set.specification.subspec_by_name(dependency.name)
@loaded_specs << spec.name @loaded_specs << spec.name
...@@ -189,11 +196,10 @@ module Pod ...@@ -189,11 +196,10 @@ module Pod
end end
set = Specification::Set::External.new(spec) set = Specification::Set::External.new(spec)
else else
set = find_set_from_sources(dependency) set = create_set_from_sources(dependency)
end end
cached_sets[name] = set cached_sets[name] = set
unless set unless set
binding.pry
raise Informative, 'Unable to find a specification for ' \ raise Informative, 'Unable to find a specification for ' \
"`#{dependency}` depended upon by #{dependent_spec}." "`#{dependency}` depended upon by #{dependent_spec}."
end end
...@@ -201,15 +207,16 @@ module Pod ...@@ -201,15 +207,16 @@ module Pod
cached_sets[name] cached_sets[name]
end end
# @return [Set] Loads a set for the Pod of the given dependency from the # @return [Set] Creates a set for the Pod of the given dependency from the
# sources. The set will be limited to the versions of the first # sources. The set will contain all versions from all sources that
# source which includes the Pod. # include the Pod.
# #
# @param [Dependency] dependency # @param [Dependency] dependency
# The dependency for which the set is needed. # The dependency for which the set is needed.
# #
def find_set_from_sources(dependency) def create_set_from_sources(dependency)
matching_sources = sources.select { |source| source.pods.include? dependency.root_name } matching_sources = sources.select { |source| source.pods.include? dependency.root_name }
unless matching_sources.empty? unless matching_sources.empty?
return Specification::Set.new(dependency.root_name, matching_sources) return Specification::Set.new(dependency.root_name, matching_sources)
end end
......
...@@ -237,17 +237,20 @@ COCOAPODS: 0.33.1 ...@@ -237,17 +237,20 @@ COCOAPODS: 0.33.1
it 'takes into account the order of the sources' do it 'takes into account the order of the sources' do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod 'JSONKit' pod 'JSONKit', '1.4'
end end
sources = SourcesManager.sources(%w(master test_repo)) sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version spec = resolver.resolve.values.flatten.first
version.to_s.should.not == '999.999.999' spec.version.to_s.should == '1.4'
spec.defined_in_file.should == fixture('spec-repos/master/Specs/JSONKit/1.4/JSONKit.podspec.json')
sources = SourcesManager.sources(%w(test_repo master)) sources = SourcesManager.sources(%w(test_repo master))
resolver = Resolver.new(config.sandbox, podfile, [], sources) resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version spec = resolver.resolve.values.flatten.first
version.to_s.should == '999.999.999' spec.version.to_s.should == '1.4'
resolver.resolve.values.flatten.first.defined_in_file.should == fixture('spec-repos/test_repo/JSONKit/1.4/JSONKit.podspec')
end 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