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

ruby-changes:39057

From: nobu <ko1@a...>
Date: Sat, 4 Jul 2015 10:43:16 +0900 (JST)
Subject: [ruby-changes:39057] nobu:r51138 (trunk): test_case.rb: fix multiple load

nobu	2015-07-04 10:43:01 +0900 (Sat, 04 Jul 2015)

  New Revision: 51138

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

  Log:
    test_case.rb: fix multiple load
    
    * lib/rubygems/test_case.rb (teardown): do not delete features
      loaded from the original load paths, the same libraries should
      be loaded again when the same features are required.
      [ruby-dev:49031] [Bug #11222]

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/test_case.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51137)
+++ ChangeLog	(revision 51138)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul  4 10:42:57 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/rubygems/test_case.rb (teardown): do not delete features
+	  loaded from the original load paths, the same libraries should
+	  be loaded again when the same features are required.
+	  [ruby-dev:49031] [Bug #11222]
+
 Sat Jul  4 09:38:52 2015  Eric Wong  <e@8...>
 
 	* vm.c (rb_vm_mark): reduce branches for always-set VM fields
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 51137)
+++ lib/rubygems/test_case.rb	(revision 51138)
@@ -342,7 +342,18 @@ class Gem::TestCase < MiniTest::Unit::Te https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L342
 
   def teardown
     $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
-    $LOADED_FEATURES.replace @orig_LOADED_FEATURES if @orig_LOADED_FEATURES
+    if @orig_LOADED_FEATURES
+      if @orig_LOAD_PATH
+        paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/")}
+        ($LOADED_FEATURES - @orig_LOADED_FEATURES).each do |feat|
+          unless paths.any? {|path| feat.start_with?(path)}
+            $LOADED_FEATURES.delete(feat)
+          end
+        end
+      else
+        $LOADED_FEATURES.replace @orig_LOADED_FEATURES
+      end
+    end
 
     if @orig_BASERUBY
       RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY

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

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