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

ruby-changes:43283

From: usa <ko1@a...>
Date: Fri, 10 Jun 2016 16:21:04 +0900 (JST)
Subject: [ruby-changes:43283] usa:r55357 (ruby_2_2): * lib/rubygems/core_ext/kernel_require.rb: -I should always win over

usa	2016-06-10 16:20:59 +0900 (Fri, 10 Jun 2016)

  New Revision: 55357

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55357

  Log:
    * lib/rubygems/core_ext/kernel_require.rb: -I should always win over
      gems.  [ruby-core:74814] [Backport #12248]

  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/lib/rubygems/core_ext/kernel_require.rb
    branches/ruby_2_2/test/rubygems/test_require.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/test/rubygems/test_require.rb
===================================================================
--- ruby_2_2/test/rubygems/test_require.rb	(revision 55356)
+++ ruby_2_2/test/rubygems/test_require.rb	(revision 55357)
@@ -49,6 +49,36 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/rubygems/test_require.rb#L49
     end
   end
 
+  # Providing -I on the commandline should always beat gems
+  def test_dash_i_beats_gems
+    a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
+    b1 = new_spec "b", "1", {"c" => "> 0"}, "lib/b/c.rb"
+    c1 = new_spec "c", "1", nil, "lib/c/c.rb"
+    c2 = new_spec "c", "2", nil, "lib/c/c.rb"
+
+    install_specs c1, c2, b1, a1
+
+    dir = Dir.mktmpdir
+    dash_i_arg = File.join Dir.mktmpdir, 'lib'
+
+    c_rb = File.join dash_i_arg, 'b', 'c.rb'
+
+    FileUtils.mkdir_p File.dirname c_rb
+    File.open(c_rb, 'w') { |f| f.write "class Object; HELLO = 'world' end" }
+
+    lp = $LOAD_PATH.dup
+
+    # Pretend to provide a commandline argument that overrides a file in gem b
+    $LOAD_PATH.unshift dash_i_arg
+
+    assert_require 'test_gem_require_a'
+    assert_require 'b/c' # this should be required from -I
+    assert_equal "world", ::Object::HELLO
+  ensure
+    $LOAD_PATH.replace lp
+    Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
+  end
+
   def test_concurrent_require
     Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
     Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 55356)
+++ ruby_2_2/version.h	(revision 55357)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-06-10"
-#define RUBY_PATCHLEVEL 332
+#define RUBY_PATCHLEVEL 333
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_2/lib/rubygems/core_ext/kernel_require.rb
===================================================================
--- ruby_2_2/lib/rubygems/core_ext/kernel_require.rb	(revision 55356)
+++ ruby_2_2/lib/rubygems/core_ext/kernel_require.rb	(revision 55357)
@@ -66,7 +66,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/rubygems/core_ext/kernel_require.rb#L66
 
     begin
       RUBYGEMS_ACTIVATION_MONITOR.exit
-      return gem_original_require(spec.to_fullpath(path) || path)
+      return gem_original_require(path)
     end if spec
 
     # Attempt to find +path+ in any unresolved gems...
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 55356)
+++ ruby_2_2/ChangeLog	(revision 55357)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Fri Jun 10 16:19:14 2016  Aaron Patterson <aaron.patterson@g...>
+
+	* lib/rubygems/core_ext/kernel_require.rb: -I should always win over
+	  gems.  [ruby-core:74814] [Backport #12248]
+
 Fri Jun 10 16:12:58 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* variable.c (rb_local_constants_i): exclude hidden constants.

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

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