summaryrefslogtreecommitdiff
path: root/test/rubygems/helper.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-03-23 20:52:19 +0100
committergit <svn-admin@ruby-lang.org>2022-03-24 07:34:29 +0900
commitd9dd88a686ee45f1200756f9e0b01fab9d3acdc5 (patch)
tree2209ffcbf1f11880f6c60f567f400477efae6ae1 /test/rubygems/helper.rb
parent8b05b5a0e14b7543f24227b9f5d5cc1f4b594a16 (diff)
[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
Diffstat (limited to 'test/rubygems/helper.rb')
-rw-r--r--test/rubygems/helper.rb2
1 files changed, 1 insertions, 1 deletions
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
# 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
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