Skip to content

Commit

Permalink
Make tests more compatible with TruffleRuby (#514)
Browse files Browse the repository at this point in the history
* Improve encoding error test case

The test input IRB currently uses happen to hit a compatibility bug in
TruffleRuby, which has been documented in
oracle/truffleruby#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 <kevin@nirvdrum.com>

* Remove redundant TruffleRuby omits/pends

Co-authored-by: Kevin Menard <kevin@nirvdrum.com>

* Use a different way to test warning emission

The test case was added in d08ef68
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 <kevin@nirvdrum.com>

---------

Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
  • Loading branch information
st0012 and nirvdrum authored Feb 9, 2023
1 parent 874dbca commit 6fdf4f3
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,19 @@ 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

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

def test_eval_input
pend if RUBY_ENGINE == 'truffleruby'
verbose, $VERBOSE = $VERBOSE, nil
input = TestInputMethod.new([
"raise 'Foo'\n",
Expand All @@ -88,7 +85,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",
Expand Down Expand Up @@ -513,7 +509,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},
Expand Down

0 comments on commit 6fdf4f3

Please sign in to comment.