Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions test/console/rdbg_option_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,70 @@ def test_debugger_doesnt_stop
end
end

class StopAtLoadOptionTest < ConsoleTestCase
def program
<<~RUBY
1| a = "foo"
2| binding.b
RUBY
end

def test_debugger_stops_immediately
run_rdbg(program, options: "--stop-at-load") do
# stops at the earliest possible location
assert_line_text(/\[C\] Kernel#require/)
type "c"
type "a + 'bar'"
assert_line_text(/foobar/)
type "c"
end
end
end

class RCFileTest < ConsoleTestCase
def rc_filename
File.join(pty_home_dir, ".rdbgrc")
end

def rc_script
"config set skip_path /foo/bar/"
end

def program
<<~RUBY
1| a = 1
RUBY
end

def with_rc_script
File.open(rc_filename, "w") { |f| f.write(rc_script) }

yield
ensure
File.delete(rc_filename)
end

def test_debugger_loads_the_rc_file_by_default
with_rc_script do
run_rdbg(program) do
type "config skip_path"
assert_line_text(/foo\\\/bar/)
type "c"
end
end
end

def test_debugger_doesnt_load_the_rc_file_with_no_rc
with_rc_script do
run_rdbg(program, options: "--no-rc") do
type "config skip_path"
assert_no_line_text(/foo\\\/bar/)
type "c"
end
end
end
end

class InitScriptTest < ConsoleTestCase
TEMPFILE_BASENAME = __FILE__.hash.abs.to_s(16)

Expand Down
2 changes: 1 addition & 1 deletion test/support/console_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def debug_code(program, remote: true, &test_steps)
end

def run_test_scenario cmd, test_info
PTY.spawn(cmd) do |read, write, pid|
PTY.spawn({ "HOME" => pty_home_dir }, cmd) do |read, write, pid|
test_info.backlog = []
test_info.last_backlog = []
begin
Expand Down
16 changes: 16 additions & 0 deletions test/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class TestCase < Test::Unit::TestCase

include AssertionHelpers

class << self
attr_reader :pty_home_dir

def startup
@pty_home_dir = Dir.mktmpdir
end

def shutdown
FileUtils.remove_entry @pty_home_dir
end
end

def setup
@temp_file = nil
end
Expand All @@ -30,6 +42,10 @@ def teardown
remove_temp_file
end

def pty_home_dir
self.class.pty_home_dir
end

def temp_file_path
@temp_file.path
end
Expand Down