diff --git a/test/support/assertions_test.rb b/test/support/assertions_test.rb index d03ad5dfb..8cf08a820 100644 --- a/test/support/assertions_test.rb +++ b/test/support/assertions_test.rb @@ -12,7 +12,7 @@ def program def test_the_helper_takes_a_string_expectation_and_escape_it assert_raise_message(/Expected to include `"foobar\\\\?/) do - debug_code(program, remote: false) do + debug_code(program) do assert_line_text("foobar?") end end @@ -49,6 +49,30 @@ def test_the_helper_raises_an_error_with_invalid_expectation end end end + + def test_the_test_fails_when_debuggee_on_unix_domain_socket_mode_doesnt_exist_after_scenarios + assert_raise_message(/Expected to include `"foobar\\\\?/) do + prepare_test_environment(program, steps) do + debug_code_on_unix_domain_socket() + end + end + end + + def test_the_test_fails_when_debuggee_on_tcpip_mode_doesnt_exist_after_scenarios + assert_raise_message(/Expected to include `"foobar\\\\?/) do + prepare_test_environment(program, steps) do + debug_code_on_tcpip() + end + end + end + + private + + def steps + Proc.new{ + assert_line_text("foobar?") + } + end end end diff --git a/test/support/console_test_case.rb b/test/support/console_test_case.rb index 1f42fa438..bd5797c39 100644 --- a/test/support/console_test_case.rb +++ b/test/support/console_test_case.rb @@ -176,11 +176,23 @@ def run_test_scenario cmd, test_info check_error(/DEBUGGEE Exception/, test_info) assert_empty_queue test_info end + + if r = test_info.remote_info + assert_program_finish test_info, r.pid, :debuggee + end + + assert_program_finish test_info, pid, :debugger # result of `gets` return this exception in some platform # https://github.com/ruby/ruby/blob/master/ext/pty/pty.c#L729-L736 rescue Errno::EIO => e check_error(/DEBUGGEE Exception/, test_info) assert_empty_queue test_info, exception: e + if r = test_info.remote_info + assert_program_finish test_info, r.pid, :debuggee + end + + assert_program_finish test_info, pid, :debugger + # result of `gets` return this exception in some platform rescue Timeout::Error assert_block(create_message("TIMEOUT ERROR (#{TIMEOUT_SEC} sec)", test_info)) { false } ensure @@ -189,13 +201,14 @@ def run_test_scenario cmd, test_info read.close write.close 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 + def assert_program_finish test_info, pid, name + assert_block(create_message("Expected the #{name} program to finish", test_info)) { wait_pid pid, TIMEOUT_SEC } + end + def prepare_test_environment(program, test_steps, &block) ENV['RUBY_DEBUG_NO_COLOR'] = 'true' ENV['RUBY_DEBUG_TEST_UI'] = 'terminal' diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 08787586c..59e3bfaa0 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -118,6 +118,8 @@ def wait_pid pid, sec end false + rescue Errno::ECHILD + true end def kill_safely pid, name, test_info diff --git a/test/support/test_case_test.rb b/test/support/test_case_test.rb index 929c67d56..b87457ac0 100644 --- a/test/support/test_case_test.rb +++ b/test/support/test_case_test.rb @@ -61,7 +61,7 @@ def steps end def test_the_test_fails_when_debuggee_on_unix_domain_socket_mode_doesnt_exist_after_scenarios - assert_raise_message(/Expected the remote program to finish/) do + assert_raise_message(/Expected the debuggee program to finish/) do prepare_test_environment(program, steps) do debug_code_on_unix_domain_socket() end @@ -69,7 +69,7 @@ def test_the_test_fails_when_debuggee_on_unix_domain_socket_mode_doesnt_exist_af end def test_the_test_fails_when_debuggee_on_tcpip_mode_doesnt_exist_after_scenarios - assert_raise_message(/Expected the remote program to finish/) do + assert_raise_message(/Expected the debuggee program to finish/) do prepare_test_environment(program, steps) do debug_code_on_tcpip() end