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

ruby-changes:71484

From: David <ko1@a...>
Date: Thu, 24 Mar 2022 07:34:44 +0900 (JST)
Subject: [ruby-changes:71484] d9dd88a686 (master): [rubygems/rubygems] Avoid crash in test teardown

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

From d9dd88a686ee45f1200756f9e0b01fab9d3acdc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 23 Mar 2022 20:52:19 +0100
Subject: [rubygems/rubygems] Avoid crash in test teardown

If an exception happens during test `setup` method, the `teardown`
method will still be run for cleaning up, but if some other errors
occurs then, it will hide the original error.

This is happening sometimes in CI where restoring original gem hooks is
failing because the error in `setup` happened before the variable
holding the original hooks was initialized.

This commit moves initialization of `@orig_hooks` to the beginning of
the `setup` method to avoid this issue.

https://github.com/rubygems/rubygems/commit/8524d2b74d
---
 test/rubygems/helper.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index d97d930476..0fff8cafe8 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -302,6 +302,7 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L302
   # or <tt>i686-darwin8.10.1</tt> otherwise.
 
   def setup
+    @orig_hooks = {}
     @orig_env = ENV.to_hash
     @tmp = File.expand_path("tmp")
 
@@ -426,7 +427,6 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L427
       util_set_arch 'i686-darwin8.10.1'
     end
 
-    @orig_hooks = {}
     %w[post_install_hooks done_installing_hooks post_uninstall_hooks pre_uninstall_hooks pre_install_hooks pre_reset_hooks post_reset_hooks post_build_hooks].each do |name|
       @orig_hooks[name] = Gem.send(name).dup
     end
-- 
cgit v1.2.1


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

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