[ruby/irb] Fix 2 minor issues in test suite
* undefine Kernel#irb_original_require in without_rdoc method * Don't rescue all LoadErrors/NameErrors in test_rendering.rb, just the one for require 'yamatanooroti' https://github.com/ruby/irb/commit/52b79806ea
This commit is contained in:
parent
a206ee6709
commit
418cf344fb
@ -57,11 +57,11 @@ module TestIRB
|
||||
end
|
||||
|
||||
def without_rdoc(&block)
|
||||
::Kernel.send(:alias_method, :old_require, :require)
|
||||
::Kernel.send(:alias_method, :irb_original_require, :require)
|
||||
|
||||
::Kernel.define_method(:require) do |name|
|
||||
raise LoadError, "cannot load such file -- rdoc (test)" if name.match?("rdoc") || name.match?(/^rdoc\/.*/)
|
||||
::Kernel.send(:old_require, name)
|
||||
::Kernel.send(:irb_original_require, name)
|
||||
end
|
||||
|
||||
yield
|
||||
@ -70,7 +70,10 @@ module TestIRB
|
||||
require_relative "../lib/envutil"
|
||||
rescue LoadError # ruby/ruby defines EnvUtil differently
|
||||
end
|
||||
EnvUtil.suppress_warning { ::Kernel.send(:alias_method, :require, :old_require) }
|
||||
EnvUtil.suppress_warning {
|
||||
::Kernel.send(:alias_method, :require, :irb_original_require)
|
||||
::Kernel.undef_method :irb_original_require
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,8 +2,13 @@ require 'irb'
|
||||
|
||||
begin
|
||||
require 'yamatanooroti'
|
||||
rescue LoadError, NameError
|
||||
# On Ruby repository, this test suite doesn't run because Ruby repo doesn't
|
||||
# have the yamatanooroti gem.
|
||||
return
|
||||
end
|
||||
|
||||
class IRB::TestRendering < Yamatanooroti::TestCase
|
||||
class IRB::TestRendering < Yamatanooroti::TestCase
|
||||
def setup
|
||||
@pwd = Dir.pwd
|
||||
suffix = '%010d' % Random.rand(0..65535)
|
||||
@ -242,8 +247,4 @@ begin
|
||||
f.write content
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue LoadError, NameError
|
||||
# On Ruby repository, this test suit doesn't run because Ruby repo doesn't
|
||||
# have the yamatanooroti gem.
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user