Skip to content

Commit 654f693

Browse files
committed
Add CDP's disconnection test
1 parent cbde3ef commit 654f693

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../support/protocol_test_case'
4+
5+
module DEBUGGER__
6+
class DisconnectCDPTest < ProtocolTestCase
7+
PROGRAM = <<~RUBY
8+
1| module Foo
9+
2| class Bar
10+
3| def self.a
11+
4| "hello"
12+
5| end
13+
6| end
14+
7| loop do
15+
8| b = 1
16+
9| end
17+
10| Bar.a
18+
11| bar = Bar.new
19+
12| end
20+
RUBY
21+
22+
def test_closing_cdp_connection_doesnt_kill_the_debuggee
23+
run_protocol_scenario PROGRAM, dap: false do
24+
req_disconnect
25+
attach_to_cdp_server
26+
req_terminate_debuggee
27+
end
28+
end
29+
end
30+
end

test/support/protocol_test_case.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def execute_cdp_scenario scenario
318318
@backlog = []
319319

320320
attach_to_cdp_server
321+
assert_cdp_connected
321322
scenario.call
322323

323324
flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC
@@ -412,6 +413,9 @@ def attach_to_cdp_server
412413
sleep 0.001 while @reader_thread.status != 'sleep'
413414
@reader_thread.run
414415
INITIALIZE_CDP_MSGS.each{|msg| send(**msg)}
416+
end
417+
418+
def assert_cdp_connected
415419
res = find_response :method, 'Debugger.paused', 'C<D'
416420
@crt_frames = res.dig(:params, :callFrames)
417421
end

0 commit comments

Comments
 (0)