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

ruby-changes:73842

From: David <ko1@a...>
Date: Mon, 3 Oct 2022 19:54:37 +0900 (JST)
Subject: [ruby-changes:73842] b7a61cb485 (master): [rubygems/rubygems] Revert "Cleaup unnecessary code"

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

From b7a61cb485a9bfaa52107f57782e53365f4bf59a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Mon, 3 Oct 2022 11:21:42 +0200
Subject: [rubygems/rubygems] Revert "Cleaup unnecessary code"

Unclear why, but https://github.com/rubygems/rubygems/commit/2e05dadbc5de created some
warnings in ruby-core CI, so let's revert it.

https://github.com/rubygems/rubygems/commit/729ce3a6e1
---
 test/rubygems/rubygems_plugin.rb |  9 +++++++++
 test/rubygems/test_gem.rb        | 11 +++++++++++
 2 files changed, 20 insertions(+)

diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb
index c18f13d2ed..b538487bbf 100644
--- a/test/rubygems/rubygems_plugin.rb
+++ b/test/rubygems/rubygems_plugin.rb
@@ -1,6 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/test/rubygems/rubygems_plugin.rb#L1
 # frozen_string_literal: true
 require "rubygems/command_manager"
 
+##
+# This is an example of exactly what NOT to do.
+#
+# DO NOT include code like this in your rubygems_plugin.rb
+
+module Gem::Commands
+  remove_const(:InterruptCommand) if defined?(InterruptCommand)
+end
+
 class Gem::Commands::InterruptCommand < Gem::Command
   def initialize
     super("interrupt", "Raises an Interrupt Exception", {})
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index f4c6e8ce76..dd2440b068 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -20,6 +20,8 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L20
     common_installer_setup
 
     @additional = %w[a b].map {|d| File.join @tempdir, d }
+
+    util_remove_interrupt_command
   end
 
   def test_self_finish_resolve
@@ -1548,10 +1550,14 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L1550
     with_plugin("load") { Gem.load_env_plugins }
     assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil
 
+    util_remove_interrupt_command
+
     # Should attempt to cause a StandardError
     with_plugin("standarderror") { Gem.load_env_plugins }
     assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil
 
+    util_remove_interrupt_command
+
     # Should attempt to cause an Exception
     with_plugin("exception") { Gem.load_env_plugins }
     assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil
@@ -2101,6 +2107,11 @@ You may need to `bundle install` to install missing gems https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L2107
     spec
   end
 
+  def util_remove_interrupt_command
+    Gem::Commands.send :remove_const, :InterruptCommand if
+      Gem::Commands.const_defined? :InterruptCommand
+  end
+
   def util_cache_dir
     File.join Gem.dir, "cache"
   end
-- 
cgit v1.2.1


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

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