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

ruby-changes:31279

From: drbrain <ko1@a...>
Date: Sat, 19 Oct 2013 06:56:33 +0900 (JST)
Subject: [ruby-changes:31279] drbrain:r43357 (trunk): * lib/rubygems: Update to RubyGems master 0a3814b. Changes:

drbrain	2013-10-19 06:56:18 +0900 (Sat, 19 Oct 2013)

  New Revision: 43357

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

  Log:
    * lib/rubygems:  Update to RubyGems master 0a3814b.  Changes:
    
      Fixed extension directory in Gem::Specification#require_paths.
    
      Allow installation of gems when $HOME is nonexistent or unwritable.
    
      Use proper API in InstallCommand.
    
      Improve support for path option in gem dependency files.
    
      Remove warnings.
    
    * test/rubygems:  ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/request_set/gem_dependency_api.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/source/installed.rb
    trunk/lib/rubygems/source.rb
    trunk/lib/rubygems/spec_fetcher.rb
    trunk/lib/rubygems/stub_specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
    trunk/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_source.rb
    trunk/test/rubygems/test_gem_spec_fetcher.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_stub_specification.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43356)
+++ ChangeLog	(revision 43357)
@@ -1,3 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 19 06:55:52 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems master 0a3814b.  Changes:
+
+	  Fixed extension directory in Gem::Specification#require_paths.
+
+	  Allow installation of gems when $HOME is nonexistent or unwritable.
+
+	  Use proper API in InstallCommand.
+
+	  Improve support for path option in gem dependency files.
+
+	  Remove warnings.
+
+	* test/rubygems:  ditto.
+
 Fri Oct 18 15:23:34 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c: change terminology of heap.
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 43356)
+++ lib/rubygems/basic_specification.rb	(revision 43357)
@@ -176,7 +176,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L176
     return @require_paths if @extensions.empty?
 
     relative_extension_install_dir =
-      File.join '..', '..', '..', 'extensions', Gem::Platform.local.to_s,
+      File.join '..', '..', 'extensions', Gem::Platform.local.to_s,
                 Gem.extension_api_version, full_name
 
     @require_paths + [relative_extension_install_dir]
Index: lib/rubygems/spec_fetcher.rb
===================================================================
--- lib/rubygems/spec_fetcher.rb	(revision 43356)
+++ lib/rubygems/spec_fetcher.rb	(revision 43357)
@@ -38,7 +38,12 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L38
   end
 
   def initialize
-    @update_cache = File.stat(Gem.user_home).uid == Process.uid
+    @update_cache =
+      begin
+        File.stat(Gem.user_home).uid == Process.uid
+      rescue Errno::EACCES, Errno::ENOENT
+        false
+      end
 
     @specs = {}
     @latest_specs = {}
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 43356)
+++ lib/rubygems/request_set.rb	(revision 43357)
@@ -159,7 +159,15 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L159
   # Resolve the requested dependencies and return an Array of Specification
   # objects to be activated.
 
-  def resolve set = nil
+  def resolve set = Gem::DependencyResolver::IndexSet.new
+    sets = [set, @vendor_set].compact
+
+    set = if sets.size == 1 then
+            sets.first
+          else
+            Gem::DependencyResolver.compose_sets(*sets)
+          end
+
     resolver = Gem::DependencyResolver.new @dependencies, set
     resolver.development  = @development
     resolver.soft_missing = @soft_missing
Index: lib/rubygems/source/installed.rb
===================================================================
--- lib/rubygems/source/installed.rb	(revision 43356)
+++ lib/rubygems/source/installed.rb	(revision 43357)
@@ -1,6 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/installed.rb#L1
 class Gem::Source::Installed < Gem::Source
 
   def initialize
+    @uri = nil
   end
 
   ##
Index: lib/rubygems/commands/install_command.rb
===================================================================
--- lib/rubygems/commands/install_command.rb	(revision 43356)
+++ lib/rubygems/commands/install_command.rb	(revision 43357)
@@ -135,7 +135,7 @@ to write the specification by hand.  For https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L135
   def execute
     if gf = options[:gemdeps] then
       install_from_gemdeps gf
-      return
+      return # not reached
     end
 
     @installed_specs = []
@@ -151,7 +151,7 @@ to write the specification by hand.  For https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L151
 
     show_installed
 
-    raise Gem::SystemExitException, exit_code
+    terminate_interaction exit_code
   end
 
   def install_from_gemdeps gf # :nodoc:
@@ -173,7 +173,7 @@ to write the specification by hand.  For https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L173
 
     @installed_specs = specs
 
-    raise Gem::SystemExitException, 0
+    terminate_interaction
   end
 
   def install_gem name, version # :nodoc:
Index: lib/rubygems/stub_specification.rb
===================================================================
--- lib/rubygems/stub_specification.rb	(revision 43356)
+++ lib/rubygems/stub_specification.rb	(revision 43357)
@@ -165,5 +165,12 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L165
     @version ||= data.version
   end
 
+  ##
+  # Is there a stub line present for this StubSpecification?
+
+  def stubbed?
+    data.is_a? StubLine
+  end
+
 end
 
Index: lib/rubygems/source.rb
===================================================================
--- lib/rubygems/source.rb	(revision 43356)
+++ lib/rubygems/source.rb	(revision 43357)
@@ -47,12 +47,7 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source.rb#L47
   include Comparable
 
   def ==(other)
-    case other
-    when self.class
-      @uri == other.uri
-    else
-      false
-    end
+    self.class === other and @uri == other.uri
   end
 
   alias_method :eql?, :==
@@ -71,7 +66,12 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source.rb#L66
   end
 
   def update_cache?
-    @update_cache ||= File.stat(Gem.user_home).uid == Process.uid
+    @update_cache ||=
+      begin
+        File.stat(Gem.user_home).uid == Process.uid
+      rescue Errno::ENOENT
+        false
+      end
   end
 
   def fetch_spec(name)
Index: lib/rubygems/request_set/gem_dependency_api.rb
===================================================================
--- lib/rubygems/request_set/gem_dependency_api.rb	(revision 43356)
+++ lib/rubygems/request_set/gem_dependency_api.rb	(revision 43357)
@@ -51,8 +51,8 @@ class Gem::RequestSet::GemDependencyAPI https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/gem_dependency_api.rb#L51
       @vendor_set.add_vendor_gem name, directory
     end
 
-    group = options.delete :group
-    all_groups  = group ? Array(group) : []
+    g = options.delete :group
+    all_groups  = g ? Array(g) : []
 
     groups = options.delete :groups
     all_groups |= groups if groups
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 43356)
+++ lib/rubygems/test_case.rb	(revision 43357)
@@ -1098,11 +1098,15 @@ Also, a list: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1098
   ##
   # A vendor_gem is used with a gem dependencies file.  The gem created here
   # has no files, just a gem specification for the given +name+ and +version+.
+  #
+  # Yields the +specification+ to the block, if given
 
   def vendor_gem name = 'a', version = 1
     directory = File.join 'vendor', name
 
-    vendor_spec = Gem::Specification.new name, version
+    vendor_spec = Gem::Specification.new name, version do |specification|
+      yield specification if block_given?
+    end
 
     FileUtils.mkdir_p directory
 
Index: test/rubygems/test_gem_spec_fetcher.rb
===================================================================
--- test/rubygems/test_gem_spec_fetcher.rb	(revision 43356)
+++ test/rubygems/test_gem_spec_fetcher.rb	(revision 43357)
@@ -52,6 +52,24 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_spec_fetcher.rb#L52
                   ['x',  Gem::Version.new(1),     'ruby']]
   end
 
+  def test_initialize_unwritable_home_dir
+    FileUtils.rmdir Gem.user_home
+
+    assert Gem::SpecFetcher.new
+  end
+
+  def test_initialize_unwritable_home_dir
+    skip 'chmod not supported' if Gem.win_platform?
+
+    FileUtils.chmod 0000, Gem.user_home
+
+    begin
+      assert Gem::SpecFetcher.new
+    ensure
+      FileUtils.chmod 0755, Gem.user_home
+    end
+  end
+
   def test_spec_for_dependency_all
     d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
     @fetcher.data["#{d}#{@a1.spec_name}.rz"]    = util_zip(Marshal.dump(@a1))
Index: test/rubygems/test_gem_request_set.rb
===================================================================
--- test/rubygems/test_gem_request_set.rb	(revision 43356)
+++ test/rubygems/test_gem_request_set.rb	(revision 43357)
@@ -56,6 +56,34 @@ class TestGemRequestSet < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set.rb#L56
     assert_equal ["a-2", "b-2"], names
   end
 
+  def test_resolve_vendor
+    a_name, _, a_directory = vendor_gem 'a', 1 do |s|
+      s.add_dependency 'b', '~> 2.0'
+    end
+
+    b_name, _, b_directory = vendor_gem 'b', 2
+
+    rs = Gem::RequestSet.new
+
+    Tempfile.open 'gem.deps.rb' do |io|
+      io.puts <<-gems_deps_rb
+        gem "#{a_name}", :path => "#{a_directory}"
+        gem "#{b_name}", :path => "#{b_directory}"
+      gems_deps_rb
+
+      io.flush
+
+      rs.load_gemdeps io.path
+    end
+
+    res = rs.resolve
+    assert_equal 2, res.size
+
+    names = res.map { |s| s.full_name }.sort
+
+    assert_equal ["a-1", "b-2"], names
+  end
+
   def test_sorted_requests
     a = util_spec "a", "2", "b" => ">= 2"
     b = util_spec "b", "2", "c" => ">= 2"
Index: test/rubygems/test_gem_stub_specification.rb
===================================================================
--- test/rubygems/test_gem_stub_specification.rb	(revision 43356)
+++ test/rubygems/test_gem_stub_specification.rb	(revision 43357)
@@ -17,6 +17,7 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_stub_specification.rb#L17
     assert_equal Gem::Version.new("0.0.1"), @foo.version
     assert_equal Gem::Platform.new("mswin32"), @foo.platform
     assert_equal ["lib", "lib/f oo/ext"], @foo.require_paths
+    assert @foo.stubbed?
   end
 
   def test_initialize_extension
@@ -24,17 +25,16 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_stub_specification.rb#L25
 
     gem_dir = File.join stub.gems_dir, stub.full_name
 
-    lib = Pathname File.join gem_dir, 'lib'
-
-    ext_install_dir =
-      Pathname(stub.extension_install_dir).relative_path_from lib
-    ext_install_dir = ext_install_dir.to_s
-
-    assert_equal 'stub_e',                  stub.name
-    assert_equal v(2),                      stub.version
-    assert_equal Gem::Platform::RUBY,       stub.platform
-    assert_equal ['lib', ext_install_dir],  stub.require_paths
-    assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
+    ext_install_dir = Pathname(stub.extension_install_dir)
+    full_gem_path = Pathname(stub.full_gem_path)
+    relative_install_dir = ext_install_dir.relative_path_from full_gem_path
+    relative_install_dir = relative_install_dir.to_s
+
+    assert_equal 'stub_e',                      stub.name
+    assert_equal v(2),                          stub.version
+    assert_equal Gem::Platform::RUBY,           stub.platform
+    assert_equal ['lib', relative_install_dir], stub.require_paths
+    assert_equal %w[ext/stub_e/extconf.rb],     stub.extensions
   end
 
   def test_initialize_missing_stubline
@@ -43,6 +43,7 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_stub_specification.rb#L43
     assert_equal Gem::Version.new("0.0.2"), stub.version
     assert_equal Gem::Platform.new("ruby"), stub.platform
     assert_equal ["lib"], stub.require_paths
+    assert !stub.stubbed?
   end
 
   def test_contains_requirable_file_eh
Index: test/rubygems/test_gem_specification.rb
===================================================================
--- test/rubygems/test_gem_specification.rb	(revision 43356)
+++ test/rubygems/test_gem_specification.rb	(revision 43357)
@@ -1659,12 +1659,11 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1659
 
     @ext.require_path = 'lib'
 
-    lib = Pathname File.join @ext.gem_dir, 'lib'
+    ext_install_dir = Pathname(@ext.extension_install_dir)
+    full_gem_path = Pathname(@ext.full_gem_path)
+    relative_install_dir = ext_install_dir.relative_path_from full_gem_path
 
-    ext_install_dir =
-      Pathname(@ext.extension_install_dir).relative_path_from lib
-
-    assert_equal ['lib', ext_install_dir.to_s], @ext.require_paths
+    assert_equal ['lib', relative_install_dir.to_s], @ext.require_paths
   ensure
     RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
   end
Index: test/rubygems/test_gem_source.rb
===================================================================
--- test/rubygems/test_gem_source.rb	(revision 43356)
+++ test/rubygems/test_gem_source.rb	(revision 43357)
@@ -207,5 +207,15 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source.rb#L207
     assert_equal(-1, remote.   <=>(no_uri),    'remote <=> no_uri')
   end
 
+  def test_update_cache_eh
+    assert @source.update_cache?
+  end
+
+  def test_update_cache_eh_home_nonexistent
+    FileUtils.rmdir Gem.user_home
+
+    refute @source.update_cache?
+  end
+
 end
 
Index: test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
===================================================================
--- test/rubygems/test_gem_dependency_resolver_vendor_specification.rb	(revision 43356)
+++ test/rubygems/test_gem_dependency_resolver_vendor_specification.rb	(revision 43357)
@@ -10,15 +10,6 @@ class TestGemDependencyResolverVendorSpe https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb#L10
     @spec = Gem::Specification.new 'a', 1
   end
 
-  def test_initialize
-    v_spec = Gem::DependencyResolver::VendorSpecification.new @set, @spec
-
-    assert_equal 'a',                     v_spec.name
-    assert_equal v(1),                    v_spec.version
-    assert_equal Gem::Platform::RUBY,     v_spec.platform
-    assert_equal Gem::Source::Vendor.new, v_spec.source
-  end
-
   def test_equals2
     v_spec_a = Gem::DependencyResolver::VendorSpecification.new @set, @spec
 
@@ -80,7 +71,7 @@ class TestGemDependencyResolverVendorSpe https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb#L71
 
     v_spec = Gem::DependencyResolver::VendorSpecification.new @set, spec
 
-    assert_equal v(1), spec.version
+    assert_equal v(1), v_spec.version
   end
 
 end
Index: test/rubygems/test_gem_commands_install_command.rb
===================================================================
--- test/rubygems/test_gem_commands_install_command.rb	(revision 43356)
+++ test/rubygems/test_gem_commands_install_command.rb	(revision 43357)
@@ -38,10 +38,9 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L38
     @cmd.options[:args] = [@a2.name]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
         @cmd.execute
       end
-      assert_equal 0, e.exit_code, @ui.error
     end
 
     assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -62,10 +61,9 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L61
     assert @cmd.options[:version].satisfied_by?(@a2_pre.version)
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
         @cmd.execute
       end
-      assert_equal 0, e.exit_code, @ui.error
     end
 
     assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -83,10 +81,9 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L81
       orig_dir = Dir.pwd
       begin
         Dir.chdir @tempdir
-        e = assert_raises Gem::SystemExitException do
+        assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
           @cmd.execute
         end
-        assert_equal 0, e.exit_code
       ensure
         Dir.chdir orig_dir
       end
@@ -131,7 +128,7 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L128
     @cmd.options[:args] = %w[no_such_gem]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      e = assert_raises Gem::MockGemUi::TermError do
         @cmd.execute
       end
       assert_equal 2, e.exit_code
@@ -156,7 +153,7 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L153
     @cmd.options[:args] = %w[nonexistent]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      e = assert_raises Gem::MockGemUi::TermError do
         @cmd.execute
       end
       assert_equal 2, e.exit_code
@@ -184,7 +181,7 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L181
     @cmd.options[:args] = %w[nonexistent]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      e = assert_raises Gem::MockGemUi::TermError do
         @cmd.execute
       end
       assert_equal 2, e.exit_code
@@ -206,7 +203,7 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L203
     @cmd.options[:args] = [misspelled]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      e = assert_raises Gem::MockGemUi::TermError do
         @cmd.execute
       end
 
@@ -230,7 +227,7 @@ ERROR:  Possible alternatives: non_exist https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L227
     @cmd.options[:args] = [misspelled]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      e = assert_raises Gem::MockGemUi::TermError do
         @cmd.execute
       end
 
@@ -273,10 +270,9 @@ ERROR:  Possible alternatives: non_exist https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L270
     @cmd.options[:args] = [@a2_pre.name]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
         @cmd.execute
       end
-      assert_equal 0, e.exit_code, @ui.error
     end
 
     assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -296,10 +292,9 @@ ERROR:  Possible alternatives: non_exist https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L292
     @cmd.options[:args] = [@a2_pre.name]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
         @cmd.execute
       end
-      assert_equal 0, e.exit_code, @ui.error
     end
 
     assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -319,10 +314,9 @@ ERROR:  Possible alternatives: non_exist https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L314
     @cmd.options[:args] = [@a2_pre.name]
 
     use_ui @ui do
-      e = assert_raises Gem::SystemExitException do
+      assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
         @cmd.execute
       end
-      assert_equal 0, e.exit_code, @ui.error
     end
 
     assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec (... truncated)

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

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