Remove limitation of exit notification only for specific API calls
This commit is contained in:
parent
00e473157a
commit
480fc02d50
13
_fixtures/pr1055.go
Normal file
13
_fixtures/pr1055.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go/ast"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
a := &ast.CompositeLit{}
|
||||||
|
fmt.Println("demo", a) // set breakpoint here and use next twice
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
@ -526,7 +526,7 @@ func (d *Debugger) Command(command *api.DebuggerCommand) (*api.DebuggerState, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if exitedErr, exited := err.(proc.ProcessExitedError); (command.Name == api.Continue || command.Name == api.Rewind) && exited {
|
if exitedErr, exited := err.(proc.ProcessExitedError); command.Name != api.SwitchGoroutine && command.Name != api.SwitchThread && exited {
|
||||||
state := &api.DebuggerState{}
|
state := &api.DebuggerState{}
|
||||||
state.Exited = true
|
state.Exited = true
|
||||||
state.ExitStatus = exitedErr.Status
|
state.ExitStatus = exitedErr.Status
|
||||||
|
@ -1387,3 +1387,32 @@ func TestClientServer_collectBreakpointInfoError(t *testing.T) {
|
|||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClientServerConsistentExit(t *testing.T) {
|
||||||
|
protest.AllowRecording(t)
|
||||||
|
// This test is useful because it ensures that Next and Continue operations both
|
||||||
|
// exit with the same exit status and details when the target application terminates.
|
||||||
|
// Other program execution API calls should also behave in the same way.
|
||||||
|
// An error should be pressent in state.Err.
|
||||||
|
withTestClient2("pr1055", t, func(c service.Client) {
|
||||||
|
fp := testProgPath(t, "pr1055")
|
||||||
|
_, err := c.CreateBreakpoint(&api.Breakpoint{File: fp, Line: 12})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
state := <-c.Continue()
|
||||||
|
if state.Err != nil {
|
||||||
|
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
||||||
|
}
|
||||||
|
state, err = c.Next()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if !state.Exited {
|
||||||
|
t.Fatal("Process state is not exited")
|
||||||
|
}
|
||||||
|
if state.ExitStatus != 2 {
|
||||||
|
t.Fatalf("Process exit status is not 2, got: %v", state.ExitStatus)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user