Skip to content

Commit

Permalink
Added matcher for setExceptionBreakpoints request
Browse files Browse the repository at this point in the history
Added a handler that does nothing
  • Loading branch information
martinwatts committed Oct 13, 2018
1 parent c0b587b commit eea2119
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ erl_crash.dump
.elixir_ls

# Run release.sh to generate this release folder
/release
/release

# Also ignore temp files created during testing
**/test/tmp
8 changes: 7 additions & 1 deletion apps/debugger/lib/debugger/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ElixirLS.Debugger.Protocol do
@moduledoc """
Macros for VS Code debug protocol requests
These macros can be used for pattern matching against incoming requests, or for creating request
These macros can be used for pattern matching against incoming requests, or for creating request
messages for use in tests.
"""
import ElixirLS.Debugger.Protocol.Basic
Expand Down Expand Up @@ -35,6 +35,12 @@ defmodule ElixirLS.Debugger.Protocol do
end
end

defmacro set_exception_breakpoints_req(seq) do
quote do
request(unquote(seq), "setExceptionBreakpoints")
end
end

defmacro configuration_done_req(seq) do
quote do
request(unquote(seq), "configurationDone")
Expand Down
4 changes: 4 additions & 0 deletions apps/debugger/lib/debugger/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ defmodule ElixirLS.Debugger.Server do
{%{"breakpoints" => breakpoints_json}, state}
end

defp handle_request(set_exception_breakpoints_req(_), state) do
{%{}, state}
end

defp handle_request(configuration_done_req(_), state) do
server = :erlang.process_info(self())[:registered_name] || self()
:int.auto_attach([:break], {__MODULE__, :breakpoint_reached, [server]})
Expand Down
27 changes: 15 additions & 12 deletions apps/debugger/test/debugger_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ defmodule ElixirLS.Debugger.ServerTest do
response(_, 3, "setBreakpoints", %{"breakpoints" => [%{"verified" => true}]})
)

Server.receive_packet(server, request(4, "configurationDone", %{}))
assert_receive(response(_, 4, "configurationDone", %{}))
Server.receive_packet(server, request(4, "setExceptionBreakpoints", %{"filters" => []}))
assert_receive(response(_, 4, "setExceptionBreakpoints", %{}))

Server.receive_packet(server, request(5, "threads", %{}))
assert_receive(response(_, 5, "threads", %{"threads" => threads}))
Server.receive_packet(server, request(5, "configurationDone", %{}))
assert_receive(response(_, 5, "configurationDone", %{}))

Server.receive_packet(server, request(6, "threads", %{}))
assert_receive(response(_, 6, "threads", %{"threads" => threads}))
# ensure thread ids are unique
thread_ids = Enum.map(threads, & &1["id"])
assert Enum.count(Enum.uniq(thread_ids)) == Enum.count(thread_ids)
Expand All @@ -68,9 +71,9 @@ defmodule ElixirLS.Debugger.ServerTest do
"threadId" => thread_id
})

Server.receive_packet(server, stacktrace_req(6, thread_id))
Server.receive_packet(server, stacktrace_req(7, thread_id))

assert_receive response(_, 6, "stackTrace", %{
assert_receive response(_, 7, "stackTrace", %{
"totalFrames" => 1,
"stackFrames" => [
%{
Expand All @@ -86,9 +89,9 @@ defmodule ElixirLS.Debugger.ServerTest do

assert String.ends_with?(path, "/lib/mix_project.ex")

Server.receive_packet(server, scopes_req(7, frame_id))
Server.receive_packet(server, scopes_req(8, frame_id))

assert_receive response(_, 7, "scopes", %{
assert_receive response(_, 8, "scopes", %{
"scopes" => [
%{
"expensive" => false,
Expand All @@ -107,9 +110,9 @@ defmodule ElixirLS.Debugger.ServerTest do
]
})

Server.receive_packet(server, vars_req(8, vars_id))
Server.receive_packet(server, vars_req(9, vars_id))

assert_receive response(_, 8, "variables", %{
assert_receive response(_, 9, "variables", %{
"variables" => [
%{
"name" => _,
Expand All @@ -120,8 +123,8 @@ defmodule ElixirLS.Debugger.ServerTest do
]
})

Server.receive_packet(server, continue_req(9, thread_id))
assert_receive response(_, 9, "continue", %{"allThreadsContinued" => false})
Server.receive_packet(server, continue_req(10, thread_id))
assert_receive response(_, 10, "continue", %{"allThreadsContinued" => false})

assert_receive(event(_, "exited", %{"exitCode" => 0}))
assert_receive(event(_, "terminated", %{"restart" => false}))
Expand Down

0 comments on commit eea2119

Please sign in to comment.