1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rubygems: Update to RubyGems master d8f12e2. This increases the

speed of `gem install --ignore-dependencies` which helps bundler
  tests.
* test/rubygems:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-12-18 01:02:58 +00:00
parent 2d493a85cf
commit 228ad3d799
7 changed files with 123 additions and 20 deletions

View file

@ -1,3 +1,10 @@
Wed Dec 18 10:00:22 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master d8f12e2. This increases the
speed of `gem install --ignore-dependencies` which helps bundler
tests.
* test/rubygems: ditto.
Wed Dec 18 09:00:17 2013 Koichi Sasada <ko1@atdot.net>
* test/ruby/test_gc.rb (test_expand_heap): allow +/-1 diff.

View file

@ -426,7 +426,8 @@ class Gem::DependencyInstaller
if @ignore_dependencies then
installer_set.ignore_dependencies = true
request_set.soft_missing = true
request_set.ignore_dependencies = true
request_set.soft_missing = true
end
composed_set = Gem::Resolver.compose_sets as, installer_set

View file

@ -32,6 +32,12 @@ class Gem::RequestSet
attr_reader :git_set # :nodoc:
##
# When true, dependency resolution is not performed, only the requested gems
# are installed.
attr_accessor :ignore_dependencies
##
# Sets used for resolution
@ -59,17 +65,18 @@ class Gem::RequestSet
def initialize *deps
@dependencies = deps
@always_install = []
@dependency_names = {}
@development = false
@git_set = nil
@install_dir = Gem.dir
@requests = []
@sets = []
@soft_missing = false
@sorted = nil
@specs = nil
@vendor_set = nil
@always_install = []
@dependency_names = {}
@development = false
@git_set = nil
@ignore_dependencies = false
@install_dir = Gem.dir
@requests = []
@sets = []
@soft_missing = false
@sorted = nil
@specs = nil
@vendor_set = nil
yield self if block_given?
end
@ -230,8 +237,9 @@ class Gem::RequestSet
set = Gem::Resolver.compose_sets(*@sets)
resolver = Gem::Resolver.new @dependencies, set
resolver.development = @development
resolver.soft_missing = @soft_missing
resolver.development = @development
resolver.ignore_dependencies = @ignore_dependencies
resolver.soft_missing = @soft_missing
@resolver = resolver

View file

@ -31,6 +31,11 @@ class Gem::Resolver
attr_accessor :development
##
# When true, no dependencies are looked up for requested gems.
attr_accessor :ignore_dependencies
##
# List of dependencies that could not be found in the configured sources.
@ -91,11 +96,12 @@ class Gem::Resolver
@set = set || Gem::Resolver::IndexSet.new
@needed = needed
@conflicts = []
@development = false
@missing = []
@soft_missing = false
@stats = Gem::Resolver::Stats.new
@conflicts = []
@development = false
@ignore_dependencies = false
@missing = []
@soft_missing = false
@stats = Gem::Resolver::Stats.new
end
def explain stage, *data # :nodoc:
@ -132,6 +138,8 @@ class Gem::Resolver
end
def requests s, act, reqs=nil # :nodoc:
return reqs if @ignore_dependencies
s.dependencies.reverse_each do |d|
next if d.type == :development and not @development
reqs.add Gem::Resolver::DependencyRequest.new(d, act)
@ -151,7 +159,7 @@ class Gem::Resolver
def resolve
@conflicts = []
needed = RequirementList.new
needed = Gem::Resolver::RequirementList.new
@needed.reverse_each do |n|
request = Gem::Resolver::DependencyRequest.new n, nil

View file

@ -1202,6 +1202,36 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_resolve %w[d-1 e-1], e1, @d1, @d2
end
def test_resolve_dependencies
util_setup_gems
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
inst = Gem::DependencyInstaller.new
request_set = inst.resolve_dependencies 'b', req('>= 0')
requests = request_set.sorted_requests.map { |req| req.full_name }
assert_equal %w[a-1 b-1], requests
end
def test_resolve_dependencies_ignore_dependencies
util_setup_gems
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
inst = Gem::DependencyInstaller.new :ignore_dependencies => true
request_set = inst.resolve_dependencies 'b', req('>= 0')
requests = request_set.sorted_requests.map { |req| req.full_name }
assert request_set.ignore_dependencies
assert_equal %w[b-1], requests
end
def util_write_a1_bin
write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
fp.puts "#!/usr/bin/ruby"

View file

@ -202,6 +202,22 @@ DEPENDENCIES
rs.sets.map { |set| set.class }
end
def test_resolve_ignore_dependencies
a = util_spec "a", "2", "b" => ">= 2"
b = util_spec "b", "2"
rs = Gem::RequestSet.new
rs.gem "a"
rs.ignore_dependencies = true
res = rs.resolve StaticSet.new([a, b])
assert_equal 1, res.size
names = res.map { |s| s.full_name }.sort
assert_equal %w[a-2], names
end
def test_resolve_incompatible
a1 = util_spec 'a', 1
a2 = util_spec 'a', 2

View file

@ -99,6 +99,39 @@ class TestGemResolver < Gem::TestCase
assert_equal 2, res.conflicts.length
end
def test_requests
a1 = util_spec 'a', 1, 'b' => 2
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
act = Gem::Resolver::ActivationRequest.new a1, r1, false
res = Gem::Resolver.new [a1]
reqs = Gem::Resolver::RequirementList.new
res.requests a1, act, reqs
assert_equal ['b (= 2)'], reqs.to_a.map { |req| req.to_s }
end
def test_requests_ignore_dependencies
a1 = util_spec 'a', 1, 'b' => 2
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
act = Gem::Resolver::ActivationRequest.new a1, r1, false
res = Gem::Resolver.new [a1]
res.ignore_dependencies = true
reqs = Gem::Resolver::RequirementList.new
res.requests a1, act, reqs
assert_empty reqs
end
def test_no_overlap_specificly
a = util_spec "a", '1'
b = util_spec "b", "1"