Include optional breakpoint info in setBreakpoints responses to reliably populate the UI (#2347)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
parent
98728d8fe1
commit
540e63a55e
@ -599,7 +599,9 @@ func (s *Server) onSetBreakpointsRequest(request *dap.SetBreakpointsRequest) {
|
|||||||
response.Body.Breakpoints[i].Line = want.Line
|
response.Body.Breakpoints[i].Line = want.Line
|
||||||
response.Body.Breakpoints[i].Message = err.Error()
|
response.Body.Breakpoints[i].Message = err.Error()
|
||||||
} else {
|
} else {
|
||||||
|
response.Body.Breakpoints[i].Id = got.ID
|
||||||
response.Body.Breakpoints[i].Line = got.Line
|
response.Body.Breakpoints[i].Line = got.Line
|
||||||
|
response.Body.Breakpoints[i].Source = dap.Source{Name: request.Arguments.Source.Name, Path: request.Arguments.Source.Path}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.send(response)
|
s.send(response)
|
||||||
|
|||||||
@ -419,8 +419,8 @@ func TestPreSetBreakpoint(t *testing.T) {
|
|||||||
t.Errorf("got %#v, want len(Breakpoints)=1", sResp)
|
t.Errorf("got %#v, want len(Breakpoints)=1", sResp)
|
||||||
}
|
}
|
||||||
bkpt0 := sResp.Body.Breakpoints[0]
|
bkpt0 := sResp.Body.Breakpoints[0]
|
||||||
if !bkpt0.Verified || bkpt0.Line != 8 {
|
if !bkpt0.Verified || bkpt0.Line != 8 || bkpt0.Id != 1 || bkpt0.Source.Name != filepath.Base(fixture.Source) || bkpt0.Source.Path != fixture.Source {
|
||||||
t.Errorf("got breakpoints[0] = %#v, want Verified=true, Line=8", bkpt0)
|
t.Errorf("got breakpoints[0] = %#v, want Verified=true, Line=8, Id=1, Path=%q", bkpt0, fixture.Source)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.SetExceptionBreakpointsRequest()
|
client.SetExceptionBreakpointsRequest()
|
||||||
@ -1456,6 +1456,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
type Breakpoint struct {
|
type Breakpoint struct {
|
||||||
line int
|
line int
|
||||||
|
path string
|
||||||
verified bool
|
verified bool
|
||||||
msgPrefix string
|
msgPrefix string
|
||||||
}
|
}
|
||||||
@ -1467,7 +1468,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i, bp := range got.Body.Breakpoints {
|
for i, bp := range got.Body.Breakpoints {
|
||||||
if bp.Line != bps[i].line || bp.Verified != bps[i].verified ||
|
if bp.Line != bps[i].line || bp.Verified != bps[i].verified || bp.Source.Path != bps[i].path ||
|
||||||
!strings.HasPrefix(bp.Message, bps[i].msgPrefix) {
|
!strings.HasPrefix(bp.Message, bps[i].msgPrefix) {
|
||||||
t.Errorf("got breakpoints[%d] = %#v, \nwant %#v", i, bp, bps[i])
|
t.Errorf("got breakpoints[%d] = %#v, \nwant %#v", i, bp, bps[i])
|
||||||
}
|
}
|
||||||
@ -1476,11 +1477,11 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Set two breakpoints at the next two lines in main
|
// Set two breakpoints at the next two lines in main
|
||||||
client.SetBreakpointsRequest(fixture.Source, []int{17, 18})
|
client.SetBreakpointsRequest(fixture.Source, []int{17, 18})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{17, true, ""}, {18, true, ""}})
|
expectSetBreakpointsResponse([]Breakpoint{{17, fixture.Source, true, ""}, {18, fixture.Source, true, ""}})
|
||||||
|
|
||||||
// Clear 17, reset 18
|
// Clear 17, reset 18
|
||||||
client.SetBreakpointsRequest(fixture.Source, []int{18})
|
client.SetBreakpointsRequest(fixture.Source, []int{18})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{18, true, ""}})
|
expectSetBreakpointsResponse([]Breakpoint{{18, fixture.Source, true, ""}})
|
||||||
|
|
||||||
// Skip 17, continue to 18
|
// Skip 17, continue to 18
|
||||||
client.ContinueRequest(1)
|
client.ContinueRequest(1)
|
||||||
@ -1490,7 +1491,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Set another breakpoint inside the loop in loop(), twice to trigger error
|
// Set another breakpoint inside the loop in loop(), twice to trigger error
|
||||||
client.SetBreakpointsRequest(fixture.Source, []int{8, 8})
|
client.SetBreakpointsRequest(fixture.Source, []int{8, 8})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{8, true, ""}, {8, false, "Breakpoint exists"}})
|
expectSetBreakpointsResponse([]Breakpoint{{8, fixture.Source, true, ""}, {8, "", false, "Breakpoint exists"}})
|
||||||
|
|
||||||
// Continue into the loop
|
// Continue into the loop
|
||||||
client.ContinueRequest(1)
|
client.ContinueRequest(1)
|
||||||
@ -1503,7 +1504,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Edit the breakpoint to add a condition
|
// Edit the breakpoint to add a condition
|
||||||
client.SetConditionalBreakpointsRequest(fixture.Source, []int{8}, map[int]string{8: "i == 3"})
|
client.SetConditionalBreakpointsRequest(fixture.Source, []int{8}, map[int]string{8: "i == 3"})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{8, true, ""}})
|
expectSetBreakpointsResponse([]Breakpoint{{8, fixture.Source, true, ""}})
|
||||||
|
|
||||||
// Continue until condition is hit
|
// Continue until condition is hit
|
||||||
client.ContinueRequest(1)
|
client.ContinueRequest(1)
|
||||||
@ -1516,7 +1517,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Edit the breakpoint to remove a condition
|
// Edit the breakpoint to remove a condition
|
||||||
client.SetConditionalBreakpointsRequest(fixture.Source, []int{8}, map[int]string{8: ""})
|
client.SetConditionalBreakpointsRequest(fixture.Source, []int{8}, map[int]string{8: ""})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{8, true, ""}})
|
expectSetBreakpointsResponse([]Breakpoint{{8, fixture.Source, true, ""}})
|
||||||
|
|
||||||
// Continue for one more loop iteration
|
// Continue for one more loop iteration
|
||||||
client.ContinueRequest(1)
|
client.ContinueRequest(1)
|
||||||
@ -1529,7 +1530,7 @@ func TestSetBreakpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Set at a line without a statement
|
// Set at a line without a statement
|
||||||
client.SetBreakpointsRequest(fixture.Source, []int{1000})
|
client.SetBreakpointsRequest(fixture.Source, []int{1000})
|
||||||
expectSetBreakpointsResponse([]Breakpoint{{1000, false, "could not find statement"}}) // all cleared, none set
|
expectSetBreakpointsResponse([]Breakpoint{{1000, "", false, "could not find statement"}}) // all cleared, none set
|
||||||
},
|
},
|
||||||
// The program has an infinite loop, so we must kill it by disconnecting.
|
// The program has an infinite loop, so we must kill it by disconnecting.
|
||||||
disconnect: true,
|
disconnect: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user