[rubygems/rubygems] Fix weirdness of "interrupt" test command

https://github.com/rubygems/rubygems/commit/0a75590ac9
This commit is contained in:
David Rodríguez 2024-09-26 12:58:10 +02:00 committed by Hiroshi SHIBATA
parent 63f31a9ed5
commit 8e73609c7b
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
4 changed files with 11 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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