@@ -7,15 +7,19 @@ module TestIRB
7
7
class RaiseExceptionTest < TestCase
8
8
def test_raise_exception_with_nil_backtrace
9
9
bundle_exec = ENV . key? ( 'BUNDLE_GEMFILE' ) ? [ '-rbundler/setup' ] : [ ]
10
- assert_in_out_err ( bundle_exec + %w[ -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , /#<Exception: foo>/ , [ ] )
10
+ libdir = File . expand_path ( "../../lib" , __dir__ )
11
+ reline_libdir = Gem . loaded_specs [ "reline" ] . full_gem_path + "/lib"
12
+ assert_in_out_err ( bundle_exec + %W[ -I#{ libdir } -I#{ reline_libdir } -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , /#<Exception: foo>/ , [ ] )
11
13
raise Exception.new("foo").tap {|e| def e.backtrace; nil; end }
12
14
IRB
13
15
end
14
16
15
17
def test_raise_exception_with_message_exception
16
18
bundle_exec = ENV . key? ( 'BUNDLE_GEMFILE' ) ? [ '-rbundler/setup' ] : [ ]
19
+ libdir = File . expand_path ( "../../lib" , __dir__ )
20
+ reline_libdir = Gem . loaded_specs [ "reline" ] . full_gem_path + "/lib"
17
21
expected = /#<Exception: foo>\n backtraces are hidden because bar was raised when processing them/
18
- assert_in_out_err ( bundle_exec + %w[ -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , expected , [ ] )
22
+ assert_in_out_err ( bundle_exec + %W[ -I #{ libdir } -I #{ reline_libdir } -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , expected , [ ] )
19
23
e = Exception.new("foo")
20
24
def e.message; raise 'bar'; end
21
25
raise e
@@ -24,8 +28,10 @@ def e.message; raise 'bar'; end
24
28
25
29
def test_raise_exception_with_message_inspect_exception
26
30
bundle_exec = ENV . key? ( 'BUNDLE_GEMFILE' ) ? [ '-rbundler/setup' ] : [ ]
31
+ libdir = File . expand_path ( "../../lib" , __dir__ )
32
+ reline_libdir = Gem . loaded_specs [ "reline" ] . full_gem_path + "/lib"
27
33
expected = /Uninspectable exception occurred/
28
- assert_in_out_err ( bundle_exec + %w[ -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , expected , [ ] )
34
+ assert_in_out_err ( bundle_exec + %W[ -I #{ libdir } -I #{ reline_libdir } -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<-IRB , expected , [ ] )
29
35
e = Exception.new("foo")
30
36
def e.message; raise; end
31
37
def e.inspect; raise; end
@@ -36,7 +42,9 @@ def e.inspect; raise; end
36
42
def test_raise_exception_with_invalid_byte_sequence
37
43
pend if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM
38
44
bundle_exec = ENV . key? ( 'BUNDLE_GEMFILE' ) ? [ '-rbundler/setup' ] : [ ]
39
- assert_in_out_err ( bundle_exec + %w[ -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<~IRB , /A\\ xF3B \( StandardError\) / , [ ] )
45
+ libdir = File . expand_path ( "../../lib" , __dir__ )
46
+ reline_libdir = Gem . loaded_specs [ "reline" ] . full_gem_path + "/lib"
47
+ assert_in_out_err ( bundle_exec + %W[ -I#{ libdir } -I#{ reline_libdir } -rirb -W0 -e IRB.start(__FILE__) -- -f -- ] , <<~IRB , /A\\ xF3B \( StandardError\) / , [ ] )
40
48
raise StandardError, "A\\ xf3B"
41
49
IRB
42
50
end
@@ -47,6 +55,8 @@ def test_raise_exception_with_different_encoding_containing_invalid_byte_sequenc
47
55
ENV [ "HOME" ] = tmpdir
48
56
49
57
bundle_exec = ENV . key? ( 'BUNDLE_GEMFILE' ) ? [ '-rbundler/setup' ] : [ ]
58
+ libdir = File . expand_path ( "../../lib" , __dir__ )
59
+ reline_libdir = Gem . loaded_specs [ "reline" ] . full_gem_path + "/lib"
50
60
File . open ( "#{ tmpdir } /euc.rb" , 'w' ) do |f |
51
61
f . write ( <<~EOF )
52
62
# encoding: euc-jp
@@ -60,7 +70,7 @@ def raise_euc_with_invalid_byte_sequence
60
70
%w( LC_MESSAGES LC_ALL LC_CTYPE LANG ) . each { |n | env [ n ] = "ja_JP.UTF-8" }
61
71
# TruffleRuby warns when the locale does not exist
62
72
env [ 'TRUFFLERUBYOPT' ] = "#{ ENV [ 'TRUFFLERUBYOPT' ] } --log.level=SEVERE" if RUBY_ENGINE == 'truffleruby'
63
- args = [ env ] + bundle_exec + %W[ -rirb -C #{ tmpdir } -W0 -e IRB.start(__FILE__) -- -f -- ]
73
+ args = [ env ] + bundle_exec + %W[ -I #{ libdir } -I #{ reline_libdir } - rirb -C #{ tmpdir } -W0 -e IRB.start(__FILE__) -- -f -- ]
64
74
error = /raise_euc_with_invalid_byte_sequence': あ\\ xFF \( RuntimeError\) /
65
75
assert_in_out_err ( args , <<~IRB , error , [ ] , encoding : "UTF-8" )
66
76
require_relative 'euc'
0 commit comments