Project

General

Profile

Bug #13843 ยป gem_resolver.patch

MSP-Greg (Greg L), 08/28/2017 01:25 PM

View differences:

lib/rubygems/resolver.rb
exc.errors = @set.errors
raise exc
end
possibles.sort_by { |s| [s.source, s.version, Gem::Platform.local =~ s.platform ? 1 : 0] }.
map { |s| ActivationRequest.new s, dependency, [] }
sources = []
groups = Hash.new { |hash, key| hash[key] = [] }
# create groups & sources in the same loop
sources = possibles.map { |spec|
source = spec.source
groups[source] << spec
source
}.uniq.reverse
activation_requests = []
sources.each do |source|
groups[source].
sort_by { |spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }.
map { |spec| ActivationRequest.new spec, dependency, [] }.
each { |activation_request| activation_requests << activation_request }
end
activation_requests
end
def dependencies_for(specification)
test/rubygems/test_gem_resolver.rb
assert_resolves_to [b1, c1, d2], r
end
def test_sorts_by_source_then_version
sourceA = Gem::Source.new 'http://example.com/a'
sourceB = Gem::Source.new 'http://example.com/b'
sourceC = Gem::Source.new 'http://example.com/c'
spec_A_1 = new_spec 'some-dep', '0.0.1'
spec_A_2 = new_spec 'some-dep', '1.0.0'
spec_B_1 = new_spec 'some-dep', '0.0.1'
spec_B_2 = new_spec 'some-dep', '0.0.2'
spec_C_1 = new_spec 'some-dep', '0.1.0'
set = StaticSet.new [
Gem::Resolver::SpecSpecification.new(nil, spec_B_1, sourceB),
Gem::Resolver::SpecSpecification.new(nil, spec_B_2, sourceB),
Gem::Resolver::SpecSpecification.new(nil, spec_C_1, sourceC),
Gem::Resolver::SpecSpecification.new(nil, spec_A_2, sourceA),
Gem::Resolver::SpecSpecification.new(nil, spec_A_1, sourceA),
]
dependency = make_dep 'some-dep', '> 0'
resolver = Gem::Resolver.new [dependency], set
assert_resolves_to [spec_B_2], resolver
end
def test_select_local_platforms
r = Gem::Resolver.new nil, nil
    (1-1/1)