service/dap: minor cosmetic changes (#1882)
- Move package doc comments so they are recognized as package doc. - Use t.Helper when appropriate.
This commit is contained in:
parent
17f2fa7908
commit
44c644ccf2
@ -1,3 +1,5 @@
|
|||||||
|
// Package daptest provides a sample client with utilities
|
||||||
|
// for DAP mode testing.
|
||||||
package daptest
|
package daptest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -12,9 +14,6 @@ import (
|
|||||||
"github.com/google/go-dap"
|
"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.
|
// Client is a debugger service client that uses Debug Adaptor Protocol.
|
||||||
// It does not (yet?) implement service.Client interface.
|
// It does not (yet?) implement service.Client interface.
|
||||||
// All client methods are synchronous.
|
// All client methods are synchronous.
|
||||||
@ -38,7 +37,7 @@ func NewClient(addr string) *Client {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the client connection
|
// Close closes the client connection.
|
||||||
func (c *Client) Close() {
|
func (c *Client) Close() {
|
||||||
c.conn.Close()
|
c.conn.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
package dap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -13,18 +21,10 @@ import (
|
|||||||
"github.com/go-delve/delve/service"
|
"github.com/go-delve/delve/service"
|
||||||
"github.com/go-delve/delve/service/api"
|
"github.com/go-delve/delve/service/api"
|
||||||
"github.com/go-delve/delve/service/debugger"
|
"github.com/go-delve/delve/service/debugger"
|
||||||
"github.com/google/go-dap"
|
"github.com/google/go-dap" // dap
|
||||||
"github.com/sirupsen/logrus"
|
"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
|
// Server implements a DAP server that can accept a single client for
|
||||||
// a single debug session. It does not support restarting.
|
// a single debug session. It does not support restarting.
|
||||||
@ -300,7 +300,7 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
|
|||||||
if mode != "exec" {
|
if mode != "exec" {
|
||||||
s.sendErrorResponse(request.Request,
|
s.sendErrorResponse(request.Request,
|
||||||
FailedToContinue, "Failed to launch",
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ func startDAPServer(t *testing.T) (server *Server, addr string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func expectMessage(t *testing.T, client *daptest.Client, want []byte) {
|
func expectMessage(t *testing.T, client *daptest.Client, want []byte) {
|
||||||
|
t.Helper()
|
||||||
got, err := client.ReadBaseMessage()
|
got, err := client.ReadBaseMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -56,9 +57,9 @@ func runTest(t *testing.T, name string, test func(c *daptest.Client, f protest.F
|
|||||||
fixture := protest.BuildFixture(name, buildFlags)
|
fixture := protest.BuildFixture(name, buildFlags)
|
||||||
|
|
||||||
server, addr := startDAPServer(t)
|
server, addr := startDAPServer(t)
|
||||||
|
defer server.Stop()
|
||||||
client := daptest.NewClient(addr)
|
client := daptest.NewClient(addr)
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
defer server.Stop()
|
|
||||||
|
|
||||||
test(client, fixture)
|
test(client, fixture)
|
||||||
}
|
}
|
||||||
@ -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 {
|
func expectErrorResponse(t *testing.T, client *daptest.Client, requestSeq int, command string, message string, id int) *dap.ErrorResponse {
|
||||||
|
t.Helper()
|
||||||
response, err := client.ReadErrorResponse()
|
response, err := client.ReadErrorResponse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user