[rubygems/rubygems] Fix weirdness of "interrupt" test command
https://github.com/rubygems/rubygems/commit/0a75590ac9
This commit is contained in:
parent
63f31a9ed5
commit
8e73609c7b
11
test/rubygems/rubygems/commands/interrupt_command.rb
Normal file
11
test/rubygems/rubygems/commands/interrupt_command.rb
Normal 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
|
@ -2,23 +2,4 @@
|
|||||||
|
|
||||||
require "rubygems/command_manager"
|
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
|
Gem::CommandManager.instance.register_command :interrupt
|
||||||
|
@ -21,8 +21,6 @@ class TestGem < Gem::TestCase
|
|||||||
common_installer_setup
|
common_installer_setup
|
||||||
|
|
||||||
@additional = %w[a b].map {|d| File.join @tempdir, d }
|
@additional = %w[a b].map {|d| File.join @tempdir, d }
|
||||||
|
|
||||||
util_remove_interrupt_command
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_finish_resolve
|
def test_self_finish_resolve
|
||||||
@ -1524,8 +1522,6 @@ class TestGem < Gem::TestCase
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
util_remove_interrupt_command
|
|
||||||
|
|
||||||
# Should attempt to cause a StandardError
|
# Should attempt to cause a StandardError
|
||||||
with_plugin("standarderror") { Gem.load_env_plugins }
|
with_plugin("standarderror") { Gem.load_env_plugins }
|
||||||
begin
|
begin
|
||||||
@ -1534,8 +1530,6 @@ class TestGem < Gem::TestCase
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
util_remove_interrupt_command
|
|
||||||
|
|
||||||
# Should attempt to cause an Exception
|
# Should attempt to cause an Exception
|
||||||
with_plugin("scripterror") { Gem.load_env_plugins }
|
with_plugin("scripterror") { Gem.load_env_plugins }
|
||||||
begin
|
begin
|
||||||
@ -1791,11 +1785,6 @@ class TestGem < Gem::TestCase
|
|||||||
spec
|
spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_remove_interrupt_command
|
|
||||||
Gem::Commands.send :remove_const, :InterruptCommand if
|
|
||||||
Gem::Commands.const_defined? :InterruptCommand
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_cache_dir
|
def util_cache_dir
|
||||||
File.join Gem.dir, "cache"
|
File.join Gem.dir, "cache"
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,6 @@ class TestGemCommandsHelpCommand < Gem::TestCase
|
|||||||
super
|
super
|
||||||
|
|
||||||
@cmd = Gem::Commands::HelpCommand.new
|
@cmd = Gem::Commands::HelpCommand.new
|
||||||
|
|
||||||
load File.expand_path("rubygems_plugin.rb", __dir__) unless Gem::Commands.const_defined? :InterruptCommand
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_help_bad
|
def test_gem_help_bad
|
||||||
|
Loading…
x
Reference in New Issue
Block a user