Skip to content

Commit 15c06fa

Browse files
ono-maxko1
authored andcommitted
Make sure to kill remote debuggee in the protocol test
1 parent 7f8f526 commit 15c06fa

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

test/support/protocol_test_case.rb

+16-12
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ def assert_watch_result expected, expression, frame_idx: 0
282282
def execute_dap_scenario scenario
283283
ENV['RUBY_DEBUG_TEST_UI'] = 'vscode'
284284

285-
@remote_info = setup_unix_domain_socket_remote_debuggee
285+
# TestInfo is defined to use kill_remote_debuggee method.
286+
test_info = TestInfo.new
287+
288+
@remote_info = test_info.remote_info = setup_unix_domain_socket_remote_debuggee
286289
Timeout.timeout(TIMEOUT_SEC) do
287290
sleep 0.001 until @remote_info.debuggee_backlog.join.include? 'connection...'
288291
end
@@ -294,21 +297,23 @@ def execute_dap_scenario scenario
294297

295298
attach_to_dap_server
296299
scenario.call
297-
298-
flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC
299300
ensure
300301
@reader_thread&.kill
301302
@sock&.close
302-
@remote_info&.reader_thread&.kill
303-
@remote_info&.r&.close
304-
@remote_info&.w&.close
303+
kill_remote_debuggee test_info
304+
if name = test_info.failed_process
305+
flunk create_protocol_message "Expected the debuggee program to finish"
306+
end
305307
end
306308

307309
def execute_cdp_scenario_ scenario
308310
ENV['RUBY_DEBUG_TEST_UI'] = 'chrome'
309311

312+
# TestInfo is defined to use kill_remote_debuggee method.
313+
test_info = TestInfo.new
314+
310315
@web_sock = nil
311-
@remote_info = setup_tcpip_remote_debuggee
316+
@remote_info = test_info.remote_info = setup_tcpip_remote_debuggee
312317
Timeout.timeout(TIMEOUT_SEC) do
313318
sleep 0.001 until @remote_info.debuggee_backlog.join.include? @remote_info.port.to_s
314319
end
@@ -320,14 +325,13 @@ def execute_cdp_scenario_ scenario
320325

321326
attach_to_cdp_server
322327
scenario.call
323-
324-
flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC
325328
ensure
326329
@reader_thread&.kill
327330
@web_sock&.close
328-
@remote_info&.reader_thread&.kill
329-
@remote_info&.r&.close
330-
@remote_info&.w&.close
331+
kill_remote_debuggee test_info
332+
if name = test_info.failed_process
333+
flunk create_protocol_message "Expected the debuggee program to finish"
334+
end
331335
end
332336

333337
def execute_cdp_scenario scenario
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# FIXME: this test doesn't pass
4+
5+
# require_relative 'protocol_test_case'
6+
7+
# module DEBUGGER__
8+
# class TestFrameworkTestHOge < ProtocolTestCase
9+
# PROGRAM = <<~RUBY
10+
# 1| a=1
11+
# RUBY
12+
13+
# def test_the_test_fails_when_debuggee_doesnt_exit
14+
# assert_fail_assertion do
15+
# run_protocol_scenario PROGRAM do
16+
# end
17+
# end
18+
# end
19+
# end
20+
# end

0 commit comments

Comments
 (0)