From 4d7975041dbf2566405c9ec04a7b077bfd41f7bc Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 3 Feb 2023 16:07:24 +0000 Subject: [PATCH 1/3] Improve encoding error test case The test input IRB currently uses happen to hit a compatibility bug in TruffleRuby, which has been documented in https://github.com/oracle/truffleruby/issues/2848 Although it'll eventually be fixed, we can make the test case support TruffleRuby now by tweaking it just a little bit. Co-authored-by: Kevin Menard --- test/irb/test_context.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 4d256a73a..de86535de 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -50,9 +50,8 @@ def test_evaluate_with_exception end def test_evaluate_with_encoding_error_without_lineno - pend if RUBY_ENGINE == 'truffleruby' assert_raise_with_message(EncodingError, /invalid symbol/) { - @context.evaluate(%q[{"\xAE": 1}], 1) + @context.evaluate(%q[:"\xAE"], 1) # The backtrace of this invalid encoding hash doesn't contain lineno. } end From 4bad4ded9ea0e981480782e6c22a4cb888a2c2a0 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 3 Feb 2023 16:15:27 +0000 Subject: [PATCH 2/3] Remove redundant TruffleRuby omits/pends Co-authored-by: Kevin Menard --- test/irb/test_context.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index de86535de..a35e6e5d9 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -64,7 +64,6 @@ def test_evaluate_with_onigmo_warning end def test_eval_input - pend if RUBY_ENGINE == 'truffleruby' verbose, $VERBOSE = $VERBOSE, nil input = TestInputMethod.new([ "raise 'Foo'\n", @@ -87,7 +86,6 @@ def test_eval_input end def test_eval_input_raise2x - pend if RUBY_ENGINE == 'truffleruby' input = TestInputMethod.new([ "raise 'Foo'\n", "raise 'Bar'\n", @@ -512,7 +510,6 @@ def test_eval_input_with_exception end def test_eval_input_with_invalid_byte_sequence_exception - pend if RUBY_ENGINE == 'truffleruby' verbose, $VERBOSE = $VERBOSE, nil input = TestInputMethod.new([ %Q{def hoge() fuga; end; def fuga() raise "A\\xF3B"; end; hoge\n}, From 5f871b474c57aee2e90e3be0bc0dcdf79ecbb4ca Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 3 Feb 2023 16:32:03 +0000 Subject: [PATCH 3/3] Use a different way to test warning emission The test case was added in https://github.com/ruby/irb/commit/d08ef68d2dfbf041d363f65686d78a937954513c to verify that IRB emits Ruby warning as expected. But the subject it uses relies on CRuby's regexp engine, which isn't always used in other language implementations, like TruffleRuby. That's why we ended up skipping TruffleRuby in this test case. Since the test isn't about regexp itself, we can change the testing subject and just remove the special condition for TruffleRuby. Co-authored-by: Kevin Menard --- test/irb/test_context.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index a35e6e5d9..c0a5164a3 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -56,10 +56,9 @@ def test_evaluate_with_encoding_error_without_lineno } end - def test_evaluate_with_onigmo_warning - pend if RUBY_ENGINE == 'truffleruby' - assert_warning("(irb):1: warning: character class has duplicated range: /[aa]/\n") do - @context.evaluate('/[aa]/', 1) + def test_evaluate_still_emits_warning + assert_warning("(irb):1: warning: END in method; use at_exit\n") do + @context.evaluate(%q[def foo; END {}; end], 1) end end