From 7e577e150a6897074bb5aaafb298b0605f00970f Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 16 Feb 2024 14:30:22 +0000 Subject: [PATCH] [ruby/irb] Fix `irb:rdbg` for ruby head (https://github.com/ruby/irb/pull/876) * Update binding.irb check for Ruby head With https://github.com/ruby/ruby/pull/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] --------- https://github.com/ruby/irb/commit/ebffd3d976 Co-authored-by: Yusuke Endoh --- lib/irb/command/debug.rb | 2 +- test/irb/test_context.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/irb/command/debug.rb b/lib/irb/command/debug.rb index 9a2c64125151cc..bdf91766bcc335 100644 --- a/lib/irb/command/debug.rb +++ b/lib/irb/command/debug.rb @@ -11,7 +11,7 @@ class Debug < Base BINDING_IRB_FRAME_REGEXPS = [ '', 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 diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 71d4aae907a5fb..059c486767cac7 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -72,7 +72,7 @@ def test_eval_input expected_output = if RUBY_3_4 [ - :*, /\(irb\):1:in '': Foo \(RuntimeError\)\n/, + :*, /\(irb\):1:in '
': Foo \(RuntimeError\)\n/, :*, /#\n/, :*, /0$/, :*, /0$/, @@ -107,8 +107,8 @@ def test_eval_input_raise2x expected_output = if RUBY_3_4 [ - :*, /\(irb\):1:in '': Foo \(RuntimeError\)\n/, - :*, /\(irb\):2:in '': Bar \(RuntimeError\)\n/, + :*, /\(irb\):1:in '
': Foo \(RuntimeError\)\n/, + :*, /\(irb\):2:in '
': Bar \(RuntimeError\)\n/, :*, /#\n/, ] else @@ -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 ''\n/, + :*, /\tfrom \(irb\):1:in '
'\n/, :* ] elsif RUBY_VERSION < '3.0.0' && STDOUT.tty? @@ -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 ''\n/, + :*, /\tfrom \(irb\):1:in '
'\n/, :* ] elsif RUBY_VERSION < '3.0.0' && STDOUT.tty?