Skip to content

Commit

Permalink
[ruby/irb] Fix irb:rdbg for ruby head
Browse files Browse the repository at this point in the history
(ruby/irb#876)

* Update binding.irb check for Ruby head

With #9605, backtrace in Ruby head
now has a new format. This commit updates the check for binding.irb
to work with Ruby head.

* Do not include a backtick in error messages and backtraces

[Feature #16495]

---------

ruby/irb@ebffd3d976

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
  • Loading branch information
2 people authored and hsbt committed Feb 19, 2024
1 parent 9ec9910 commit 7e577e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/irb/command/debug.rb
Expand Up @@ -11,7 +11,7 @@ class Debug < Base
BINDING_IRB_FRAME_REGEXPS = [
'<internal:prelude>',
binding.method(:irb).source_location.first,
].map { |file| /\A#{Regexp.escape(file)}:\d+:in `irb'\z/ }
].map { |file| /\A#{Regexp.escape(file)}:\d+:in (`|'Binding#)irb'\z/ }

def execute(pre_cmds: nil, do_cmds: nil)
if irb_context.with_debugger
Expand Down
10 changes: 5 additions & 5 deletions test/irb/test_context.rb
Expand Up @@ -72,7 +72,7 @@ def test_eval_input
expected_output =
if RUBY_3_4
[
:*, /\(irb\):1:in '<top \(required\)>': Foo \(RuntimeError\)\n/,
:*, /\(irb\):1:in '<main>': Foo \(RuntimeError\)\n/,
:*, /#<RuntimeError: Foo>\n/,
:*, /0$/,
:*, /0$/,
Expand Down Expand Up @@ -107,8 +107,8 @@ def test_eval_input_raise2x
expected_output =
if RUBY_3_4
[
:*, /\(irb\):1:in '<top \(required\)>': Foo \(RuntimeError\)\n/,
:*, /\(irb\):2:in '<top \(required\)>': Bar \(RuntimeError\)\n/,
:*, /\(irb\):1:in '<main>': Foo \(RuntimeError\)\n/,
:*, /\(irb\):2:in '<main>': Bar \(RuntimeError\)\n/,
:*, /#<RuntimeError: Bar>\n/,
]
else
Expand Down Expand Up @@ -531,7 +531,7 @@ def test_eval_input_with_exception
[
:*, /\(irb\):1:in 'fuga': unhandled exception\n/,
:*, /\tfrom \(irb\):1:in 'hoge'\n/,
:*, /\tfrom \(irb\):1:in '<top \(required\)>'\n/,
:*, /\tfrom \(irb\):1:in '<main>'\n/,
:*
]
elsif RUBY_VERSION < '3.0.0' && STDOUT.tty?
Expand Down Expand Up @@ -569,7 +569,7 @@ def test_eval_input_with_invalid_byte_sequence_exception
[
:*, /\(irb\):1:in 'fuga': A\\xF3B \(RuntimeError\)\n/,
:*, /\tfrom \(irb\):1:in 'hoge'\n/,
:*, /\tfrom \(irb\):1:in '<top \(required\)>'\n/,
:*, /\tfrom \(irb\):1:in '<main>'\n/,
:*
]
elsif RUBY_VERSION < '3.0.0' && STDOUT.tty?
Expand Down

0 comments on commit 7e577e1

Please sign in to comment.