Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to kill remote debuggee in the protocol test #813

Merged
merged 1 commit into from
Nov 22, 2022
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
28 changes: 16 additions & 12 deletions test/support/protocol_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/support/protocol_test_case_test.rb
Original file line number Diff line number Diff line change
@@ -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