diff --git a/test/irb/test_option.rb b/test/irb/test_option.rb index e8622fc7b..a3a40c0b9 100644 --- a/test/irb/test_option.rb +++ b/test/irb/test_option.rb @@ -7,7 +7,8 @@ def test_end_of_option bug4117 = '[ruby-core:33574]' bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) - status = assert_in_out_err(bundle_exec + %W[-W0 -I#{libdir} -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" + status = assert_in_out_err(bundle_exec + %W[-W0 -I#{libdir} -I#{reline_libdir} -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117) assert(status.success?, bug4117) end end diff --git a/test/irb/test_raise_exception.rb b/test/irb/test_raise_exception.rb index 2c8136ba9..133f073f5 100644 --- a/test/irb/test_raise_exception.rb +++ b/test/irb/test_raise_exception.rb @@ -8,7 +8,8 @@ class RaiseExceptionTest < TestCase def test_raise_exception_with_nil_backtrace bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) - assert_in_out_err(bundle_exec + %W[-I#{libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /#/, []) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" + assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /#/, []) raise Exception.new("foo").tap {|e| def e.backtrace; nil; end } IRB end @@ -16,8 +17,9 @@ def test_raise_exception_with_nil_backtrace def test_raise_exception_with_message_exception bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" expected = /#\nbacktraces are hidden because bar was raised when processing them/ - assert_in_out_err(bundle_exec + %W[-I#{libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, []) + assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, []) e = Exception.new("foo") def e.message; raise 'bar'; end raise e @@ -27,8 +29,9 @@ def e.message; raise 'bar'; end def test_raise_exception_with_message_inspect_exception bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" expected = /Uninspectable exception occurred/ - assert_in_out_err(bundle_exec + %W[-I#{libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, []) + assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, []) e = Exception.new("foo") def e.message; raise; end def e.inspect; raise; end @@ -40,7 +43,8 @@ def test_raise_exception_with_invalid_byte_sequence pend if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) - assert_in_out_err(bundle_exec + %W[-I#{libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<~IRB, /A\\xF3B \(StandardError\)/, []) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" + assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<~IRB, /A\\xF3B \(StandardError\)/, []) raise StandardError, "A\\xf3B" IRB end @@ -52,6 +56,7 @@ def test_raise_exception_with_different_encoding_containing_invalid_byte_sequenc bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] libdir = File.expand_path("../../lib", __dir__) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" File.open("#{tmpdir}/euc.rb", 'w') do |f| f.write(<<~EOF) # encoding: euc-jp @@ -65,7 +70,7 @@ def raise_euc_with_invalid_byte_sequence %w(LC_MESSAGES LC_ALL LC_CTYPE LANG).each {|n| env[n] = "ja_JP.UTF-8" } # TruffleRuby warns when the locale does not exist env['TRUFFLERUBYOPT'] = "#{ENV['TRUFFLERUBYOPT']} --log.level=SEVERE" if RUBY_ENGINE == 'truffleruby' - args = [env] + bundle_exec + %W[-I#{libdir} -rirb -C #{tmpdir} -W0 -e IRB.start(__FILE__) -- -f --] + args = [env] + bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -C #{tmpdir} -W0 -e IRB.start(__FILE__) -- -f --] error = /raise_euc_with_invalid_byte_sequence': あ\\xFF \(RuntimeError\)/ assert_in_out_err(args, <<~IRB, error, [], encoding: "UTF-8") require_relative 'euc' diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 8911a6cd4..9392b49fa 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -201,7 +201,8 @@ def test_assignment_expression_with_local_variable def test_initialising_the_old_top_level_ruby_lex libdir = File.expand_path("../../lib", __dir__) - assert_in_out_err(["-I#{libdir}", "--disable-gems", "-W:deprecated"], <<~RUBY, [], /warning: constant ::RubyLex is deprecated/) + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" + assert_in_out_err(["-I#{libdir}", "-I#{reline_libdir}", "--disable-gems", "-W:deprecated"], <<~RUBY, [], /warning: constant ::RubyLex is deprecated/) require "irb" ::RubyLex.new(nil) RUBY diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb index 62166abfd..99ade80f6 100644 --- a/test/irb/test_workspace.rb +++ b/test/irb/test_workspace.rb @@ -84,12 +84,13 @@ def test_toplevel_binding_local_variables bug17623 = '[ruby-core:102468]' bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] top_srcdir = "#{__dir__}/../.." + reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib" irb_path = nil %w[exe libexec].find do |dir| irb_path = "#{top_srcdir}/#{dir}/irb" File.exist?(irb_path) end or omit 'irb command not found' - assert_in_out_err(bundle_exec + ['-W0', "-I#{top_srcdir}/lib", "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623) + assert_in_out_err(bundle_exec + ['-W0', "-I#{top_srcdir}/lib", "-I#{reline_libdir}", "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623) version = 'xyz' # typical rubygems loading file load('#{irb_path}') RUBY