Skip to content

Commit

Permalink
add verbose mode for debug_code
Browse files Browse the repository at this point in the history
show backlog if verbose is true.
  • Loading branch information
ko1 committed Dec 11, 2023
1 parent d4feeae commit 52694a9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/support/console_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_message fail_msg, test_info
MSG
end

def debug_code(program, remote: true, &test_steps)
def debug_code(program, remote: true, verbose: false, &test_steps)
Timeout.timeout(60) do
prepare_test_environment(program, test_steps) do
if remote && !NO_REMOTE && MULTITHREADED_TEST
Expand All @@ -109,17 +109,17 @@ def debug_code(program, remote: true, &test_steps)
th.each {|t| t.join}
end
elsif remote && !NO_REMOTE
debug_code_on_local unless remote == :remote_only
debug_code_on_local verbose: verbose unless remote == :remote_only
debug_code_on_unix_domain_socket
debug_code_on_tcpip
else
debug_code_on_local unless remote == :remote_only
debug_code_on_local verbose: verbose unless remote == :remote_only
end
end
end
end

def run_test_scenario cmd, test_info
def run_test_scenario cmd, test_info, verbose: false
PTY.spawn({ "HOME" => pty_home_dir }, cmd) do |read, write, pid|
test_info.backlog = []
test_info.last_backlog = []
Expand Down Expand Up @@ -206,6 +206,8 @@ def run_test_scenario cmd, test_info
kill_safely pid, force: is_assertion_failure
end
end
ensure
pp backlog: test_info.backlog if verbose
end

def assert_program_finish test_info, pid, name
Expand Down Expand Up @@ -249,10 +251,10 @@ def manual_debug_code(program)
kill_remote_debuggee remote_info
end

private def debug_code_on_local
private def debug_code_on_local verbose: false
test_info = TestInfo.new(dup_scenario, 'LOCAL', /\(rdbg\)/)
cmd = "#{RDBG_EXECUTABLE} #{temp_file_path}"
run_test_scenario cmd, test_info
run_test_scenario cmd, test_info, verbose: verbose
end

private def debug_code_on_unix_domain_socket
Expand Down

0 comments on commit 52694a9

Please sign in to comment.