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

Do not override an existed thread in the testing framework #511

Merged
merged 1 commit into from
Feb 5, 2022
Merged
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
12 changes: 6 additions & 6 deletions test/support/dap_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,22 @@ def create_protocol_msg test_info, fail_msg
}
]

DAP_TestInfo = Struct.new(:res_backlog, :backlog, :failed_process, :remote_info)
DAP_TestInfo = Struct.new(:res_backlog, :backlog, :failed_process, :reader_thread, :remote_info)

class Detach < StandardError
end

def connect_to_dap_server test_info
remote_info = test_info.remote_info
sock = Socket.unix remote_info.sock_path
remote_info.reader_thread = Thread.new(sock, test_info) do |s, info|
test_info.reader_thread = Thread.new(sock, test_info) do |s, info|
while res = recv_request(s, info.backlog)
info.res_backlog << res
end
rescue Detach
end
sleep 0.001 while remote_info.reader_thread.status != 'sleep'
remote_info.reader_thread.run
sleep 0.001 while test_info.reader_thread.status != 'sleep'
test_info.reader_thread.run
sock
end

Expand Down Expand Up @@ -198,7 +198,7 @@ def run_dap_scenario program, &msgs

if msg[:command] == 'disconnect'
res_log.clear
remote_info.reader_thread.raise Detach
test_info.reader_thread.raise Detach
sock.close
end
when 'event'
Expand All @@ -215,7 +215,7 @@ def run_dap_scenario program, &msgs
rescue Timeout::Error
flunk create_protocol_msg test_info, "TIMEOUT ERROR (#{TIMEOUT_SEC} sec) while waiting for the following response.\n#{JSON.pretty_generate target_msg}"
ensure
remote_info.reader_thread.kill
test_info.reader_thread.kill
sock.close
kill_safely remote_info.pid, :debuggee, test_info
if test_info.failed_process
Expand Down