Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 17abf5e

Browse files
committedOct 26, 2023
Support activating IRB as console with a config
1 parent 85fa62a commit 17abf5e

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
 

‎lib/debug/config.rb

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module DEBUGGER__
2222
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
2323
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
2424
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
25+
irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"],
2526

2627
# control setting
2728
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],

‎lib/debug/session.rb

+5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false
202202
end
203203
@tp_thread_end.enable
204204

205+
if CONFIG[:irb_console]
206+
require_relative "irb_integration"
207+
thc.activate_irb_integration
208+
end
209+
205210
# session start
206211
q << true
207212
session_server_main

‎test/console/irb_test.rb

+17
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,22 @@ def test_irb_command_switches_console_to_irb
2424
type 'q!'
2525
end
2626
end
27+
28+
def test_irb_console_config_activates_irb
29+
ENV["RUBY_DEBUG_IRB_CONSOLE"] = "true"
30+
31+
debug_code(program, remote: false) do
32+
type '123'
33+
assert_line_text 'irb:rdbg(main):002> 123'
34+
type 'irb_info'
35+
assert_line_text('IRB version:')
36+
type 'next'
37+
type 'info'
38+
assert_line_text([/a = 1/, /b = nil/])
39+
type 'q!'
40+
end
41+
ensure
42+
ENV["RUBY_DEBUG_IRB_CONSOLE"] = nil
43+
end
2744
end
2845
end

0 commit comments

Comments
 (0)
Please sign in to comment.