service/dap: send terminated event when disconnecting (#2587)
* service/dap: send terminated event when disconnecting If the program terminates while disconnecting, either because it was killed or otherwise, send a terminated event.
This commit is contained in:
parent
175ca0c769
commit
890cde3d4c
@ -637,6 +637,7 @@ func TestDap(t *testing.T) {
|
||||
client := daptest.NewClient(listenAddr)
|
||||
client.DisconnectRequest()
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
if _, err := client.ReadMessage(); err != io.EOF {
|
||||
t.Errorf("got %q, want \"EOF\"\n", err)
|
||||
}
|
||||
|
||||
@ -972,6 +972,10 @@ func (s *Server) onDisconnectRequest(request *dap.DisconnectRequest) {
|
||||
} else {
|
||||
s.send(&dap.DisconnectResponse{Response: *newResponse(request.Request)})
|
||||
}
|
||||
// The debugging session has ended, so we send a terminated event.
|
||||
s.send(&dap.TerminatedEvent{
|
||||
Event: *newEvent("terminated"),
|
||||
})
|
||||
}
|
||||
|
||||
// stopDebugSession is called from Stop (main goroutine) and
|
||||
|
||||
@ -246,6 +246,7 @@ func TestLaunchStopOnEntry(t *testing.T) {
|
||||
if dResp.Seq != 0 || dResp.RequestSeq != 13 {
|
||||
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=13", dResp)
|
||||
}
|
||||
client.ExpectTerminatedEvent(t)
|
||||
})
|
||||
}
|
||||
|
||||
@ -377,6 +378,7 @@ func TestAttachStopOnEntry(t *testing.T) {
|
||||
client.CheckOutputEvent(t, msg)
|
||||
msg = expectMessageFilterStopped(t, client)
|
||||
client.CheckDisconnectResponse(t, msg)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
|
||||
// If this call to KeepAlive isn't here there's a chance that stdout will
|
||||
// be garbage collected (since it is no longer alive long before this
|
||||
@ -452,6 +454,7 @@ func TestContinueOnEntry(t *testing.T) {
|
||||
if dResp.Seq != 0 || dResp.RequestSeq != 8 {
|
||||
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=8", dResp)
|
||||
}
|
||||
client.ExpectTerminatedEvent(t)
|
||||
})
|
||||
}
|
||||
|
||||
@ -591,6 +594,7 @@ func TestPreSetBreakpoint(t *testing.T) {
|
||||
client.ExpectOutputEventProcessExited(t, 0)
|
||||
client.ExpectOutputEventDetaching(t)
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
})
|
||||
}
|
||||
|
||||
@ -3854,6 +3858,7 @@ func runDebugSessionWithBPs(t *testing.T, client *daptest.Client, cmd string, cm
|
||||
client.ExpectOutputEventDetachingKill(t)
|
||||
}
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
return
|
||||
}
|
||||
client.ContinueRequest(1)
|
||||
@ -3872,6 +3877,7 @@ func runDebugSessionWithBPs(t *testing.T, client *daptest.Client, cmd string, cm
|
||||
client.ExpectOutputEventDetachingKill(t)
|
||||
}
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
}
|
||||
|
||||
// runDebugSession is a helper for executing the standard init and shutdown
|
||||
@ -3996,6 +4002,7 @@ func runNoDebugDebugSession(t *testing.T, client *daptest.Client, cmdRequest fun
|
||||
client.ExpectTerminatedEvent(t)
|
||||
client.DisconnectRequestWithKillOption(true)
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
}
|
||||
|
||||
func TestLaunchTestRequest(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user