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

ruby-changes:61544

From: Benoit <ko1@a...>
Date: Fri, 5 Jun 2020 07:34:24 +0900 (JST)
Subject: [ruby-changes:61544] 5f0e84ba8d (master): [rubygems/rubygems] Fix check for testing in the ruby repository

https://git.ruby-lang.org/ruby.git/commit/?id=5f0e84ba8d

From 5f0e84ba8df4faf5f58882958a79a794b95e94c8 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Wed, 22 Apr 2020 21:20:06 +0200
Subject: [rubygems/rubygems] Fix check for testing in the ruby repository

* When testing in the rubygems/rubygems repository, the previous code would
  move the lib/ dir at the end of $LOAD_PATH, which would cause to load
  a mix of lib/ RubyGems and in-stdlib-dir RubyGems, which blows up.

https://github.com/rubygems/rubygems/commit/f6f6f00ed1

diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index e61fb41..9e66be5 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -252,11 +252,14 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L252
       stdlib one is already in $LOADED_FEATURES?. Reproducible by running the
       spaceship_specific_file test before this one" if java_platform?
 
-    lp = $LOAD_PATH.dup
-    lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../lib"))
-    if File.exist?(lib_dir)
+    lib_dir = File.expand_path("../../lib", File.dirname(__FILE__))
+    if RbConfig::CONFIG["rubylibdir"] == lib_dir
+      # testing in the ruby repository where RubyGems' lib/ == stdlib lib/
+      # In that case we want to move the stdlib lib/ to still be after b-2 in $LOAD_PATH
+      lp = $LOAD_PATH.dup
       $LOAD_PATH.delete lib_dir
       $LOAD_PATH.push lib_dir
+      load_path_changed = true
     end
 
     require 'benchmark' # the stdlib
@@ -269,6 +272,7 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L272
 
     # Activates a-1, but not b-1 and b-2
     assert_require 'test_gem_require_a'
+    assert_equal %w[a-1], loaded_spec_names
     assert $LOAD_PATH.include? a1.load_paths[0]
     refute $LOAD_PATH.include? b1.load_paths[0]
     refute $LOAD_PATH.include? b2.load_paths[0]
@@ -281,7 +285,10 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L285
     # and that still exists in $LOAD_PATH (further down),
     # and as a result #gem_original_require returns false.
     refute require('benchmark'), "the benchmark stdlib should be recognized as already loaded"
+
     assert $LOAD_PATH.include? b2.load_paths[0]
+    assert $LOAD_PATH.index(b2.load_paths[0]) < $LOAD_PATH.index(RbConfig::CONFIG["rubylibdir"]),
+      "this test relies on the b-2 gem lib/ to be before stdlib to make sense"
 
     # We detected that we should activate b-2, so we did so, but
     # then #gem_original_require decided "I've already got some benchmark.rb" loaded.
@@ -290,7 +297,7 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L297
 
     assert_equal %w[a-1 b-2], loaded_spec_names
   ensure
-    $LOAD_PATH.replace lp unless java_platform?
+    $LOAD_PATH.replace lp if load_path_changed
   end
 
   def test_already_activated_direct_conflict
-- 
cgit v0.10.2


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

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