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:
Alessandro Arzilli
2022-01-19 19:40:54 +01:00
committed by GitHub
parent df8c2b37ce
commit b3e528e4fb
2 changed files with 35 additions and 6 deletions

View File

@ -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")
}
})
}