diff --git a/test/support/protocol_test_case.rb b/test/support/protocol_test_case.rb index 4970742a4..057ddb8f1 100644 --- a/test/support/protocol_test_case.rb +++ b/test/support/protocol_test_case.rb @@ -282,7 +282,10 @@ def assert_watch_result expected, expression, frame_idx: 0 def execute_dap_scenario scenario ENV['RUBY_DEBUG_TEST_UI'] = 'vscode' - @remote_info = setup_unix_domain_socket_remote_debuggee + # TestInfo is defined to use kill_remote_debuggee method. + test_info = TestInfo.new + + @remote_info = test_info.remote_info = setup_unix_domain_socket_remote_debuggee Timeout.timeout(TIMEOUT_SEC) do sleep 0.001 until @remote_info.debuggee_backlog.join.include? 'connection...' end @@ -294,21 +297,23 @@ def execute_dap_scenario scenario attach_to_dap_server scenario.call - - flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC ensure @reader_thread&.kill @sock&.close - @remote_info&.reader_thread&.kill - @remote_info&.r&.close - @remote_info&.w&.close + kill_remote_debuggee test_info + if name = test_info.failed_process + flunk create_protocol_message "Expected the debuggee program to finish" + end end def execute_cdp_scenario_ scenario ENV['RUBY_DEBUG_TEST_UI'] = 'chrome' + # TestInfo is defined to use kill_remote_debuggee method. + test_info = TestInfo.new + @web_sock = nil - @remote_info = setup_tcpip_remote_debuggee + @remote_info = test_info.remote_info = setup_tcpip_remote_debuggee Timeout.timeout(TIMEOUT_SEC) do sleep 0.001 until @remote_info.debuggee_backlog.join.include? @remote_info.port.to_s end @@ -320,14 +325,13 @@ def execute_cdp_scenario_ scenario attach_to_cdp_server scenario.call - - flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC ensure @reader_thread&.kill @web_sock&.close - @remote_info&.reader_thread&.kill - @remote_info&.r&.close - @remote_info&.w&.close + kill_remote_debuggee test_info + if name = test_info.failed_process + flunk create_protocol_message "Expected the debuggee program to finish" + end end def execute_cdp_scenario scenario diff --git a/test/support/protocol_test_case_test.rb b/test/support/protocol_test_case_test.rb new file mode 100644 index 000000000..2f9e494e3 --- /dev/null +++ b/test/support/protocol_test_case_test.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# FIXME: this test doesn't pass + +# require_relative 'protocol_test_case' + +# module DEBUGGER__ +# class TestFrameworkTestHOge < ProtocolTestCase +# PROGRAM = <<~RUBY +# 1| a=1 +# RUBY + +# def test_the_test_fails_when_debuggee_doesnt_exit +# assert_fail_assertion do +# run_protocol_scenario PROGRAM do +# end +# end +# end +# end +# end