Skip to content

Commit

Permalink
Support activating IRB as console with a config
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Oct 26, 2023
1 parent 85fa62a commit 17abf5e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module DEBUGGER__
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"],

# control setting
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],
Expand Down
5 changes: 5 additions & 0 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false
end
@tp_thread_end.enable

if CONFIG[:irb_console]
require_relative "irb_integration"
thc.activate_irb_integration
end

# session start
q << true
session_server_main
Expand Down
17 changes: 17 additions & 0 deletions test/console/irb_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,22 @@ def test_irb_command_switches_console_to_irb
type 'q!'
end
end

def test_irb_console_config_activates_irb
ENV["RUBY_DEBUG_IRB_CONSOLE"] = "true"

debug_code(program, remote: false) do
type '123'
assert_line_text 'irb:rdbg(main):002> 123'
type 'irb_info'
assert_line_text('IRB version:')
type 'next'
type 'info'
assert_line_text([/a = 1/, /b = nil/])
type 'q!'
end
ensure
ENV["RUBY_DEBUG_IRB_CONSOLE"] = nil
end
end
end

0 comments on commit 17abf5e

Please sign in to comment.