mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 09:46:56 +08:00
service/dap: deflake DAP tests (#2872)
1. change ExpectOutputEventProcessExited to accept -1 exit status, this is a real problem on linux but we don't know how to fix it and we already have a test in proc for it. 2. change TestNoDebug_AcceptNoRequestButDisconnect to be less picky about message ordering, all message orderings seem to be fine, there is no reason to insist on a particular one, since the DAP server is unable to actually produce it deterministically. Fixes #2860
This commit is contained in:
committed by
GitHub
parent
df8c2b37ce
commit
b3e528e4fb
@ -5353,11 +5353,39 @@ func TestNoDebug_AcceptNoRequestsButDisconnect(t *testing.T) {
|
||||
|
||||
// Disconnect request is ok
|
||||
client.DisconnectRequestWithKillOption(true)
|
||||
client.ExpectOutputEventTerminating(t)
|
||||
client.ExpectOutputEventRegex(t, fmt.Sprintf(daptest.ProcessExited, "(-1|1)"))
|
||||
client.ExpectTerminatedEvent(t)
|
||||
client.ExpectDisconnectResponse(t)
|
||||
client.ExpectTerminatedEvent(t)
|
||||
terminated, disconnectResp := false, false
|
||||
for {
|
||||
m, err := client.ReadMessage()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
switch m := m.(type) {
|
||||
case *dap.OutputEvent:
|
||||
ok := false
|
||||
wants := []string{`Terminating process [0-9]+\n`, fmt.Sprintf(daptest.ProcessExited, "(-1|1)")}
|
||||
for _, want := range wants {
|
||||
if matched, _ := regexp.MatchString(want, m.Body.Output); matched {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
t.Errorf("\ngot %#v\nwant Output=%q\n", m, wants)
|
||||
}
|
||||
case *dap.TerminatedEvent:
|
||||
terminated = true
|
||||
case *dap.DisconnectResponse:
|
||||
disconnectResp = true
|
||||
default:
|
||||
t.Errorf("got unexpected message %#v", m)
|
||||
}
|
||||
}
|
||||
if !terminated {
|
||||
t.Errorf("did not get TerminatedEvent")
|
||||
}
|
||||
if !disconnectResp {
|
||||
t.Errorf("did not get DisconnectResponse")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user