From 8e73609c7b4c7fdc35e47cefd8f696777c0da5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 26 Sep 2024 12:58:10 +0200 Subject: [PATCH] [rubygems/rubygems] Fix weirdness of "interrupt" test command https://github.com/rubygems/rubygems/commit/0a75590ac9 --- .../rubygems/commands/interrupt_command.rb | 11 +++++++++++ test/rubygems/rubygems_plugin.rb | 19 ------------------- test/rubygems/test_gem.rb | 11 ----------- .../test_gem_commands_help_command.rb | 2 -- 4 files changed, 11 insertions(+), 32 deletions(-) create mode 100644 test/rubygems/rubygems/commands/interrupt_command.rb diff --git a/test/rubygems/rubygems/commands/interrupt_command.rb b/test/rubygems/rubygems/commands/interrupt_command.rb new file mode 100644 index 0000000000..88d2ef22e7 --- /dev/null +++ b/test/rubygems/rubygems/commands/interrupt_command.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Gem::Commands::InterruptCommand < Gem::Command + def initialize + super("interrupt", "Raises an Interrupt Exception", {}) + end + + def execute + raise Interrupt, "Interrupt exception" + end +end diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb index 949580f904..f9f2a7d911 100644 --- a/test/rubygems/rubygems_plugin.rb +++ b/test/rubygems/rubygems_plugin.rb @@ -2,23 +2,4 @@ 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", {}) - end - - def execute - raise Interrupt, "Interrupt exception" - end -end - Gem::CommandManager.instance.register_command :interrupt diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index e8a294d65c..0d048b08b7 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -21,8 +21,6 @@ class TestGem < Gem::TestCase common_installer_setup @additional = %w[a b].map {|d| File.join @tempdir, d } - - util_remove_interrupt_command end def test_self_finish_resolve @@ -1524,8 +1522,6 @@ class TestGem < Gem::TestCase nil end - util_remove_interrupt_command - # Should attempt to cause a StandardError with_plugin("standarderror") { Gem.load_env_plugins } begin @@ -1534,8 +1530,6 @@ class TestGem < Gem::TestCase nil end - util_remove_interrupt_command - # Should attempt to cause an Exception with_plugin("scripterror") { Gem.load_env_plugins } begin @@ -1791,11 +1785,6 @@ class TestGem < Gem::TestCase 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 diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb index 359da0a6d0..01ab4aab2f 100644 --- a/test/rubygems/test_gem_commands_help_command.rb +++ b/test/rubygems/test_gem_commands_help_command.rb @@ -11,8 +11,6 @@ class TestGemCommandsHelpCommand < Gem::TestCase super @cmd = Gem::Commands::HelpCommand.new - - load File.expand_path("rubygems_plugin.rb", __dir__) unless Gem::Commands.const_defined? :InterruptCommand end def test_gem_help_bad