service/dap: generate continued events for step tests (#2525)

This commit is contained in:
Suzy Mueller 2021-06-03 12:50:53 -04:00 committed by GitHub
parent d72b03b846
commit 054e3f8ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 17 deletions

@ -43,7 +43,12 @@ func (c *Client) Check{{.}}(t *testing.T, m dap.Message) *dap.{{.}} {
r, ok := m.(*dap.{{.}})
if !ok {
t.Fatalf("got %#v, want *dap.{{.}}", m)
}
}{{if or (or (eq . "StepInResponse") (eq . "StepOutResponse")) (eq . "NextResponse") }}
m = c.ExpectMessage(t)
_, ok = m.(*dap.ContinuedEvent)
if !ok {
t.Fatalf("got %#v, want *dap.ContinuedEvent", m)
}{{end}}
return r
}{{end}}
`))

@ -492,6 +492,11 @@ func (c *Client) CheckNextResponse(t *testing.T, m dap.Message) *dap.NextRespons
if !ok {
t.Fatalf("got %#v, want *dap.NextResponse", m)
}
m = c.ExpectMessage(t)
_, ok = m.(*dap.ContinuedEvent)
if !ok {
t.Fatalf("got %#v, want *dap.ContinuedEvent", m)
}
return r
}
@ -906,6 +911,11 @@ func (c *Client) CheckStepInResponse(t *testing.T, m dap.Message) *dap.StepInRes
if !ok {
t.Fatalf("got %#v, want *dap.StepInResponse", m)
}
m = c.ExpectMessage(t)
_, ok = m.(*dap.ContinuedEvent)
if !ok {
t.Fatalf("got %#v, want *dap.ContinuedEvent", m)
}
return r
}
@ -942,6 +952,11 @@ func (c *Client) CheckStepOutResponse(t *testing.T, m dap.Message) *dap.StepOutR
if !ok {
t.Fatalf("got %#v, want *dap.StepOutResponse", m)
}
m = c.ExpectMessage(t)
_, ok = m.(*dap.ContinuedEvent)
if !ok {
t.Fatalf("got %#v, want *dap.ContinuedEvent", m)
}
return r
}

@ -1697,7 +1697,6 @@ func TestVariablesLoading(t *testing.T) {
// step into another function
client.StepInRequest(1)
client.ExpectStepInResponse(t)
client.ExpectContinuedEvent(t)
client.ExpectStoppedEvent(t)
checkStop(t, client, 1, "main.barfoo", 24)
loadvars(1001 /*second frame here is same as topmost above*/)
@ -1745,7 +1744,6 @@ func TestGlobalScopeAndVariables(t *testing.T) {
// Step into pkg.AnotherMethod()
client.StepInRequest(1)
client.ExpectStepInResponse(t)
client.ExpectContinuedEvent(t)
client.ExpectStoppedEvent(t)
client.StackTraceRequest(1, 0, 20)
@ -2260,7 +2258,6 @@ func TestSetBreakpointWhileRunning(t *testing.T) {
// We can set breakpoints while nexting
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
client.SetBreakpointsRequest(fixture.Source, []int{15}) // [16,] => [15,]
se, br := expectSetBreakpointsResponseAndStoppedEvent(t, client)
if se.Body.Reason != "pause" || !se.Body.AllThreadsStopped || se.Body.ThreadId != 0 && se.Body.ThreadId != 1 {
@ -2316,7 +2313,6 @@ func TestSetFunctionBreakpointWhileRunning(t *testing.T) {
// We can set breakpoints while nexting
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
client.SetFunctionBreakpointsRequest([]dap.FunctionBreakpoint{{Name: "main.sayhi"}}) // [16,] => [16, 8]
se, br := expectSetFunctionBreakpointsResponseAndStoppedEvent(t, client)
if se.Body.Reason != "pause" || !se.Body.AllThreadsStopped || se.Body.ThreadId != 0 && se.Body.ThreadId != 1 {
@ -2973,22 +2969,18 @@ func TestNextAndStep(t *testing.T) {
client.StepOutRequest(1)
client.ExpectStepOutResponse(t)
client.ExpectContinuedEvent(t)
expectStop("main.main", 18)
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
expectStop("main.main", 19)
client.StepInRequest(1)
client.ExpectStepInResponse(t)
client.ExpectContinuedEvent(t)
expectStop("main.inlineThis", 5)
client.NextRequest(-1000)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
if se := client.ExpectStoppedEvent(t); se.Body.Reason != "error" || se.Body.Text != "unknown goroutine -1000" {
t.Errorf("got %#v, want Reason=\"error\", Text=\"unknown goroutine -1000\"", se)
}
@ -3017,7 +3009,6 @@ func TestNextParked(t *testing.T) {
client.NextRequest(goroutineId)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != goroutineId {
@ -3047,7 +3038,6 @@ func TestStepInParked(t *testing.T) {
client.StepInRequest(goroutineId)
client.ExpectStepInResponse(t)
client.ExpectContinuedEvent(t)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != goroutineId {
@ -3167,7 +3157,6 @@ func TestStepOutPreservesGoroutine(t *testing.T) {
}
client.StepOutRequest(goroutineId)
client.ExpectStepOutResponse(t)
client.ExpectContinuedEvent(t)
switch e := client.ExpectMessage(t).(type) {
case *dap.StoppedEvent:
@ -3221,22 +3210,18 @@ func TestBadAccess(t *testing.T) {
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
expectStoppedOnError("invalid memory address or nil pointer dereference")
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
expectStoppedOnError("next while nexting")
client.StepInRequest(1)
client.ExpectStepInResponse(t)
client.ExpectContinuedEvent(t)
expectStoppedOnError("next while nexting")
client.StepOutRequest(1)
client.ExpectStepOutResponse(t)
client.ExpectContinuedEvent(t)
expectStoppedOnError("next while nexting")
},
disconnect: true,
@ -3297,7 +3282,6 @@ func TestPanicBreakpointOnNext(t *testing.T) {
client.NextRequest(1)
client.ExpectNextResponse(t)
client.ExpectContinuedEvent(t)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != 1 || se.Body.Reason != "exception" || se.Body.Description != "Paused on panic" {