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

Update protocol tests #720

Merged
merged 3 commits 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
20 changes: 16 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ Execute debugging `program` with `&scenario`. If you want to test it only for DA

`run_protocol_scenario program, cdp: false ...`

- attach_to_dap_server(terminate_debuggee:)

Attach to the running DAP server through UNIX Domain Socket.

- attach_to_cdp_server

Attach to the running CDP server through TCP/IP.

- req_dap_disconnect

Disconnect from the currently connected DAP server.

- req_cdp_disconnect

Disconnect from the currently connected CDP server.

- req_add_breakpoint(lineno, path: temp_file_path, cond: nil)

Sends request to rdbg to add a breakpoint.
Expand Down Expand Up @@ -377,10 +393,6 @@ Sends request to rdbg to step back from current method.

Sends request to rdbg to terminate the debuggee.

- assert_reattach

Passes if reattaching to rdbg is successful.

- assert_hover_result(expected, expression)

Passes if result of `expression` matches `expected`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

__END__

require_relative '../support/protocol_test_case'

module DEBUGGER__
class DetachTest < ProtocolTestCase
class DisconnectCDPTest < ProtocolTestCase
PROGRAM = <<~RUBY
1| module Foo
2| class Bar
Expand All @@ -21,9 +19,10 @@ class DetachTest < ProtocolTestCase
12| end
RUBY

def test_detach_reattach_to_rdbg
run_protocol_scenario PROGRAM do
assert_reattach
def test_closing_cdp_connection_doesnt_kill_the_debuggee
run_protocol_scenario PROGRAM, dap: false do
req_cdp_disconnect
attach_to_cdp_server
req_terminate_debuggee
end
end
Expand Down
52 changes: 52 additions & 0 deletions test/protocol/disconnect_dap_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

require_relative '../support/protocol_test_case'

module DEBUGGER__

class DisconnectDAPTest < ProtocolTestCase
PROGRAM = <<~RUBY
1| module Foo
2| class Bar
3| def self.a
4| "hello"
5| end
6| end
7| loop do
8| b = 1
9| end
10| Bar.a
11| bar = Bar.new
12| end
RUBY

def test_disconnect_without_terminateDebuggee_keeps_debuggee_alive
run_protocol_scenario PROGRAM, cdp: false do
req_dap_disconnect(terminate_debuggee: false)
attach_to_dap_server
st0012 marked this conversation as resolved.
Show resolved Hide resolved
assert_reattached
# suspends the debuggee so it'll take the later requests (include terminate)
suspend_debugee
req_terminate_debuggee
end
end

def test_disconnect_with_terminateDebuggee_kills_debuggee
run_protocol_scenario PROGRAM, cdp: false do
req_dap_disconnect(terminate_debuggee: true)
end
end

private

def suspend_debugee
send_dap_request "pause", threadId: 1
end

def assert_reattached
st0012 marked this conversation as resolved.
Show resolved Hide resolved
res = find_crt_dap_response
result_cmd = res.dig(:command)
assert_equal 'configurationDone', result_cmd
end
end
end
197 changes: 0 additions & 197 deletions test/protocol/restart_raw_dap_test.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

module DEBUGGER__

class RestartTest < ProtocolTestCase
class TerminateTest < ProtocolTestCase
PROGRAM = <<~RUBY
1| a = 1
RUBY

def test_restart
def test_terminate_request_terminates_the_debuggee
run_protocol_scenario PROGRAM do
req_terminate_debuggee
end
Expand Down
Loading