Skip to content

Commit

Permalink
service/dap: fix TestNextParked/TestStepInParked (go-delve#2643)
Browse files Browse the repository at this point in the history
The loop searching for a suitable goroutine is not guaranteed to ever
find it, and failing to find one is not an error.

Changes testStepParkedHelper to match the behavior of TestNextParked in
proc_test.go.
Deletes TestStepInParked because it does not test anything meaningful
beyond what's already tested by TestNextParked.
  • Loading branch information
aarzilli authored Aug 4, 2021
1 parent 4e24209 commit 2971fd4
Showing 1 changed file with 14 additions and 36 deletions.
50 changes: 14 additions & 36 deletions service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3459,43 +3459,15 @@ func TestNextParked(t *testing.T) {
fixture.Source, []int{15},
[]onBreakpoint{{ // Stop at line 15
execute: func() {
goroutineId := testStepParkedHelper(t, client, fixture)
if goroutineId := testStepParkedHelper(t, client, fixture); goroutineId >= 0 {

client.NextRequest(goroutineId)
client.ExpectNextResponse(t)

se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != goroutineId {
t.Fatalf("Next did not continue on the selected goroutine, expected %d got %d", goroutineId, se.Body.ThreadId)
}
},
disconnect: false,
}})
})
}

func TestStepInParked(t *testing.T) {
if runtime.GOOS == "freebsd" {
t.SkipNow()
}
runTest(t, "parallel_next", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequest("exec", fixture.Path, !stopOnEntry)
},
// Set breakpoints
fixture.Source, []int{15},
[]onBreakpoint{{ // Stop at line 15
execute: func() {
goroutineId := testStepParkedHelper(t, client, fixture)

client.StepInRequest(goroutineId)
client.ExpectStepInResponse(t)
client.NextRequest(goroutineId)
client.ExpectNextResponse(t)

se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != goroutineId {
t.Fatalf("StepIn did not continue on the selected goroutine, expected %d got %d", goroutineId, se.Body.ThreadId)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != goroutineId {
t.Fatalf("Next did not continue on the selected goroutine, expected %d got %d", goroutineId, se.Body.ThreadId)
}
}
},
disconnect: false,
Expand All @@ -3512,7 +3484,13 @@ func testStepParkedHelper(t *testing.T, client *daptest.Client, fixture protest.
var goroutineId = -1
for goroutineId < 0 {
client.ContinueRequest(1)
client.ExpectContinueResponse(t)
contResp := client.ExpectMessage(t)
switch contResp.(type) {
case *dap.ContinueResponse:
// ok
case *dap.TerminatedEvent:
return -1
}

se := client.ExpectStoppedEvent(t)

Expand Down

0 comments on commit 2971fd4

Please sign in to comment.