Skip to content

Commit

Permalink
service/dap: minor cosmetic changes (go-delve#1882)
Browse files Browse the repository at this point in the history
- Move package doc comments so they are recognized as package doc.
- Use t.Helper when appropriate.
  • Loading branch information
hyangah authored Feb 21, 2020
1 parent 17f2fa7 commit 44c644c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
7 changes: 3 additions & 4 deletions service/dap/daptest/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package daptest provides a sample client with utilities
// for DAP mode testing.
package daptest

import (
Expand All @@ -12,9 +14,6 @@ import (
"github.com/google/go-dap"
)

// Package daptest provides a sample client with utilities
// for DAP mode testing.

// Client is a debugger service client that uses Debug Adaptor Protocol.
// It does not (yet?) implement service.Client interface.
// All client methods are synchronous.
Expand All @@ -38,7 +37,7 @@ func NewClient(addr string) *Client {
return c
}

// Close closes the client connection
// Close closes the client connection.
func (c *Client) Close() {
c.conn.Close()
}
Expand Down
20 changes: 10 additions & 10 deletions service/dap/server.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Package dap implements VSCode's Debug Adaptor Protocol (DAP).
// This allows delve to communicate with frontends using DAP
// without a separate adaptor. The frontend will run the debugger
// (which now doubles as an adaptor) in server mode listening on
// a port and communicating over TCP. This is work in progress,
// so for now Delve in dap mode only supports synchronous
// request-response communication, blocking while processing each request.
// For DAP details see https://microsoft.github.io/debug-adapter-protocol.
package dap

import (
Expand All @@ -13,18 +21,10 @@ import (
"github.com/go-delve/delve/service"
"github.com/go-delve/delve/service/api"
"github.com/go-delve/delve/service/debugger"
"github.com/google/go-dap"
"github.com/google/go-dap" // dap
"github.com/sirupsen/logrus"
)

// Package dap implements VSCode's Debug Adaptor Protocol (DAP).
// This allows delve to communicate with frontends using DAP
// without a separate adaptor. The frontend will run the debugger
// (which now doubles as an adaptor) in server mode listening on
// a port and communicating over TCP. This is work in progress,
// so for now Delve in dap mode only supports synchronous
// request-response communication, blocking while processing each request.
// For DAP details see https://microsoft.github.io/debug-adapter-protocol.

// Server implements a DAP server that can accept a single client for
// a single debug session. It does not support restarting.
Expand Down Expand Up @@ -300,7 +300,7 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
if mode != "exec" {
s.sendErrorResponse(request.Request,
FailedToContinue, "Failed to launch",
fmt.Sprintf("Unsupported 'mode' value '%s' in debug configuration.", mode))
fmt.Sprintf("Unsupported 'mode' value %q in debug configuration.", mode))
return
}

Expand Down
4 changes: 3 additions & 1 deletion service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func startDAPServer(t *testing.T) (server *Server, addr string) {
}

func expectMessage(t *testing.T, client *daptest.Client, want []byte) {
t.Helper()
got, err := client.ReadBaseMessage()
if err != nil {
t.Error(err)
Expand All @@ -56,9 +57,9 @@ func runTest(t *testing.T, name string, test func(c *daptest.Client, f protest.F
fixture := protest.BuildFixture(name, buildFlags)

server, addr := startDAPServer(t)
defer server.Stop()
client := daptest.NewClient(addr)
defer client.Close()
defer server.Stop()

test(client, fixture)
}
Expand Down Expand Up @@ -123,6 +124,7 @@ func TestSetBreakpoint(t *testing.T) {
}

func expectErrorResponse(t *testing.T, client *daptest.Client, requestSeq int, command string, message string, id int) *dap.ErrorResponse {
t.Helper()
response, err := client.ReadErrorResponse()
if err != nil {
t.Error(err)
Expand Down

0 comments on commit 44c644c

Please sign in to comment.