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
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ Passes if `text` is not included in the last debugger log.

Passes if `text` is included in the debuggee log.

- assert_finish

Passes if debugger finishes correctly.

## To Update README

This project generates `README.md` from the template `misc/README.md.erb`
Expand Down
2 changes: 0 additions & 2 deletions test/debug/break_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def test_break_C_method_with_singleton_method
type 'c'
assert_line_text(/:3\b/)
type 'c'
assert_finish
end
end
end
Expand Down Expand Up @@ -496,7 +495,6 @@ def test_conditional_breakpoint_shows_error
type 'c'
assert_debuggee_line_text(/EVAL ERROR/)
type 'c'
assert_finish
end
end

Expand Down
3 changes: 0 additions & 3 deletions test/debug/config_postmortem_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def test_config_postmortem
type 'step'
assert_line_text(/Can not use this command on postmortem mode/)
type 'c'
assert_finish
end
end

Expand All @@ -46,7 +45,6 @@ def test_env_var_postmortem
type 'step'
assert_line_text(/Can not use this command on postmortem mode/)
type 'c'
assert_finish
end
ensure
ENV["RUBY_DEBUG_POSTMORTEM"] = nil
Expand Down Expand Up @@ -89,7 +87,6 @@ def test_config_postmortem
type 'p v'
assert_line_text(/=> :ok1/)
type 'c'
assert_finish
end
end
end
Expand Down
1 change: 0 additions & 1 deletion test/debug/control_flow_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ def test_finish_4
type 'c'
assert_line_num 8
type 'fin 4'
assert_finish
end
end

Expand Down
1 change: 0 additions & 1 deletion test/debug/info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_info_print_modified_locals
type 'info'
assert_line_text(/a = 128\b/)
type 'c'
assert_finish
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions test/debug/kill_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def test_kill_kills_the_debugger_process_if_confirmed
type 'kill'
assert_line_text(/Really kill\? \[Y\/n\]/)
type 'y'
assert_finish
end
end

Expand All @@ -25,14 +24,12 @@ def test_kill_does_not_kill_the_debugger_process_if_not_confirmed
assert_line_text(/Really kill\? \[Y\/n\]/)
type 'n'
type 'q!'
assert_finish
end
end

def test_kill_with_exclamation_mark_kills_the_debugger_process_immediately
debug_code(program) do
type "kill!"
assert_finish
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions test/debug/quit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def test_quit_quits_debugger_process_if_confirmed
type 'q'
assert_line_text(/Really quit\? \[Y\/n\]/)
type 'y'
assert_finish
end
end

Expand All @@ -25,14 +24,12 @@ def test_quit_does_not_quit_debugger_process_if_not_confirmed
assert_line_text(/Really quit\? \[Y\/n\]/)
type 'n'
type 'q!'
assert_finish
end
end

def test_quit_with_exclamation_mark_quits_immediately_debugger_process
debug_code(program) do
type 'q!'
assert_finish
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions test/debug/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_debugger_session_starts_correctly
type 'c'
assert_line_num(6)
type 'c'
assert_finish
end
end
end
Expand All @@ -44,7 +43,6 @@ def test_debugger_session_starts_correctly
type 'c'
assert_line_num(3)
type 'c'
assert_finish
end
end
end
Expand All @@ -68,7 +66,6 @@ def test_debugger_session_starts_correctly
type 'c'
assert_line_num(6)
type 'c'
assert_finish
end
end
end
Expand Down
10 changes: 0 additions & 10 deletions test/support/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,11 @@ def assert_block msg
end
end

def assert_finish
@scenario.push(method(:flunk_finish))
end

private

def collect_recent_backlog(last_backlog)
last_backlog[1..].join
end

def flunk_finish test_info
msg = 'Expected the debugger program to finish'

assert_block(FailureMessage.new { create_message(msg, test_info) }) { false }
end
end
end

Expand Down
41 changes: 19 additions & 22 deletions test/support/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_message fail_msg, test_info
end

TestInfo = Struct.new(:queue, :mode, :prompt_pattern, :remote_info,
:backlog, :last_backlog, :internal_info)
:backlog, :last_backlog, :internal_info, :failed_process)

RemoteInfo = Struct.new(:r, :w, :pid, :sock_path, :port, :reader_thread, :debuggee_backlog)

Expand Down Expand Up @@ -199,6 +199,7 @@ def run_test_scenario cmd, test_info
is_ask_cmd = false

loop do
assert_block(FailureMessage.new { create_message "Expected the REPL prompt to finish", test_info }) { !test_info.queue.empty? }
cmd = test_info.queue.pop

case cmd.to_s
Expand Down Expand Up @@ -241,11 +242,14 @@ def run_test_scenario cmd, test_info
rescue Timeout::Error => e
assert_block(create_message("TIMEOUT ERROR (#{TIMEOUT_SEC} sec)", test_info)) { false }
ensure
kill_remote_debuggee test_info.remote_info
kill_remote_debuggee test_info
# kill debug console process
read.close
write.close
kill_safely pid, :debugger
kill_safely pid, :debugger, test_info
if name = test_info.failed_process
assert_block(create_message("Expected the #{name} program to finish", test_info)) { false }
end
end
end
end
Expand All @@ -268,10 +272,12 @@ def wait_pid pid, sec
false
end

def kill_safely pid, name
return if wait_pid pid, 0.3
def kill_safely pid, name, test_info
return if wait_pid pid, 3

test_info.failed_process = name

Process.kill :KILL, pid
Process.kill :TERM, pid
return if wait_pid pid, 0.2

Process.kill :KILL, pid
Expand All @@ -295,13 +301,13 @@ def check_error(error, test_info)
end
end

def kill_remote_debuggee remote_info
return unless remote_info
def kill_remote_debuggee test_info
return unless r = test_info.remote_info

remote_info.reader_thread.kill
remote_info.r.close
remote_info.w.close
kill_safely remote_info.pid, :remote
r.reader_thread.kill
r.r.close
r.w.close
kill_safely r.pid, :remote, test_info
end

# use this to start a debug session with the test program
Expand Down Expand Up @@ -366,16 +372,7 @@ def assert_empty_queue test_info, exception: nil
message += "\nAssociated exception: #{exception.class} - #{exception.message}" +
exception.backtrace.map{|l| " #{l}\n"}.join
end
assert_block(FailureMessage.new { create_message message, test_info }) do
return true if test_info.queue.empty?

case test_info.queue.pop.to_s
when /flunk_finish/
true
else
false
end
end
assert_block(FailureMessage.new { create_message message, test_info }) { test_info.queue.empty? }
end

def strip_line_num(str)
Expand Down
8 changes: 7 additions & 1 deletion test/test_utils_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ def test_the_test_fails_when_the_script_doesnt_have_line_numbers
def test_the_test_work_when_debuggee_outputs_many_lines
debug_code ' 1| 300.times{|i| p i}' do
type 'c'
assert_finish
end
end

def test_the_test_fails_when_the_repl_prompt_does_not_finish_even_though_scenario_is_empty
assert_raise_message(/Expected the REPL prompt to finish/) do
debug_code(program) do
end
end
end
end
Expand Down