[前][次][番号順一覧][スレッド一覧]

ruby-changes:32191

From: drbrain <ko1@a...>
Date: Wed, 18 Dec 2013 10:03:08 +0900 (JST)
Subject: [ruby-changes:32191] drbrain:r44270 (trunk): * lib/rubygems: Update to RubyGems master d8f12e2. This increases the

drbrain	2013-12-18 10:02:58 +0900 (Wed, 18 Dec 2013)

  New Revision: 44270

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44270

  Log:
    * lib/rubygems:  Update to RubyGems master d8f12e2.  This increases the
      speed of `gem install --ignore-dependencies` which helps bundler
      tests.
    * test/rubygems:  ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/dependency_installer.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/resolver.rb
    trunk/test/rubygems/test_gem_dependency_installer.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_resolver.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44269)
+++ ChangeLog	(revision 44270)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 18 10:00:22 2013  Eric Hodel  <drbrain@s...>
+
+	* 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@a...>
 
 	* test/ruby/test_gc.rb (test_expand_heap): allow +/-1 diff.
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb	(revision 44269)
+++ lib/rubygems/dependency_installer.rb	(revision 44270)
@@ -426,7 +426,8 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L426
 
     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
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 44269)
+++ lib/rubygems/request_set.rb	(revision 44270)
@@ -33,6 +33,12 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L33
   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
 
   attr_reader :sets # :nodoc:
@@ -59,17 +65,18 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L65
   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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L237
     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
 
Index: lib/rubygems/resolver.rb
===================================================================
--- lib/rubygems/resolver.rb	(revision 44269)
+++ lib/rubygems/resolver.rb	(revision 44270)
@@ -32,6 +32,11 @@ class Gem::Resolver https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver.rb#L32
   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.
 
   attr_reader :missing
@@ -91,11 +96,12 @@ class Gem::Resolver https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver.rb#L96
     @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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver.rb#L138
   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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver.rb#L159
   def resolve
     @conflicts = []
 
-    needed = RequirementList.new
+    needed = Gem::Resolver::RequirementList.new
 
     @needed.reverse_each do |n|
       request = Gem::Resolver::DependencyRequest.new n, nil
Index: test/rubygems/test_gem_request_set.rb
===================================================================
--- test/rubygems/test_gem_request_set.rb	(revision 44269)
+++ test/rubygems/test_gem_request_set.rb	(revision 44270)
@@ -202,6 +202,22 @@ DEPENDENCIES https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L202
                  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
Index: test/rubygems/test_gem_dependency_installer.rb
===================================================================
--- test/rubygems/test_gem_dependency_installer.rb	(revision 44269)
+++ test/rubygems/test_gem_dependency_installer.rb	(revision 44270)
@@ -1202,6 +1202,36 @@ class TestGemDependencyInstaller < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency_installer.rb#L1202
     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"
Index: test/rubygems/test_gem_resolver.rb
===================================================================
--- test/rubygems/test_gem_resolver.rb	(revision 44269)
+++ test/rubygems/test_gem_resolver.rb	(revision 44270)
@@ -99,6 +99,39 @@ class TestGemResolver < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_resolver.rb#L99
     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"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]