diff --git a/test/support/console_test_case.rb b/test/support/console_test_case.rb index 081b3f335..976a9f908 100644 --- a/test/support/console_test_case.rb +++ b/test/support/console_test_case.rb @@ -195,12 +195,20 @@ def run_test_scenario cmd, test_info # result of `gets` return this exception in some platform rescue Timeout::Error assert_block(create_message("TIMEOUT ERROR (#{TIMEOUT_SEC} sec)", test_info)) { false } + rescue Test::Unit::AssertionFailedError + is_fail = true + raise ensure - kill_remote_debuggee test_info + kill_remote_debuggee(test_info, failed: is_fail == true) # kill debug console process read.close write.close - kill_safely pid, :debugger, test_info + if is_fail == true + kill_safely pid, :debugger, test_info, sec: 0 + end + if name = test_info.failed_process && !is_fail + flunk(create_message("Expected the #{name} program to finish", test_info)) + end end end end diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 976ad30fc..ea89c069e 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -122,8 +122,8 @@ def wait_pid pid, sec true end - def kill_safely pid, name, test_info - return if wait_pid pid, TIMEOUT_SEC + def kill_safely pid, name, test_info, sec: TIMEOUT_SEC + return if wait_pid pid, sec test_info.failed_process = name @@ -141,10 +141,14 @@ def check_error(error, test_info) end end - def kill_remote_debuggee test_info + def kill_remote_debuggee test_info, failed: false return unless r = test_info.remote_info - kill_safely r.pid, :remote, test_info + if failed + kill_safely r.pid, :remote, test_info, sec: 2 + else + kill_safely r.pid, :remote, test_info + end r.reader_thread.kill # Because the debuggee may be terminated by executing the following operations, we need to run them after `kill_safely` method. r.r.close