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
set = find_cached_set(dependency, dependent_spec)
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)
spec = set.specification.subspec_by_name(dependency.name)
@loaded_specs << spec.name
......@@ -189,11 +196,10 @@ module Pod
end
set = Specification::Set::External.new(spec)
else
set = find_set_from_sources(dependency)
set = create_set_from_sources(dependency)
end
cached_sets[name] = set
unless set
binding.pry
raise Informative, 'Unable to find a specification for ' \
"`#{dependency}` depended upon by #{dependent_spec}."
end
......@@ -201,15 +207,16 @@ module Pod
cached_sets[name]
end
# @return [Set] Loads a set for the Pod of the given dependency from the
# sources. The set will be limited to the versions of the first
# source which includes the Pod.
# @return [Set] Creates a set for the Pod of the given dependency from the
# sources. The set will contain all versions from all sources that
# include the Pod.
#
# @param [Dependency] dependency
# 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 }
unless matching_sources.empty?
return Specification::Set.new(dependency.root_name, matching_sources)
end
......
......@@ -237,17 +237,20 @@ COCOAPODS: 0.33.1
it 'takes into account the order of the sources' do
podfile = Podfile.new do
platform :ios
pod 'JSONKit'
pod 'JSONKit', '1.4'
end
sources = SourcesManager.sources(%w(master test_repo))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version
version.to_s.should.not == '999.999.999'
spec = resolver.resolve.values.flatten.first
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))
resolver = Resolver.new(config.sandbox, podfile, [], sources)
version = resolver.resolve.values.flatten.first.version
version.to_s.should == '999.999.999'
spec = resolver.resolve.values.flatten.first
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
......
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