proc/tests: use Detach(true) instead of Kill in tests (#765)
The rest of the code uses Detach to "close" a proc.Process, the tests should do the same. Any cleanup that proc.Process needs to do can then be put inside Detach and the tests will run it.
This commit is contained in:
parent
bb07fc36b9
commit
cda7316421
@ -112,6 +112,9 @@ func (pe ProcessExitedError) Error() string {
|
|||||||
|
|
||||||
// Detach from the process being debugged, optionally killing it.
|
// Detach from the process being debugged, optionally killing it.
|
||||||
func (dbp *Process) Detach(kill bool) (err error) {
|
func (dbp *Process) Detach(kill bool) (err error) {
|
||||||
|
if dbp.exited {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if dbp.Running() {
|
if dbp.Running() {
|
||||||
if err = dbp.Halt(); err != nil {
|
if err = dbp.Halt(); err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -40,7 +40,7 @@ func withTestProcess(name string, t testing.TB, fn func(p *Process, fixture prot
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
p.Halt()
|
p.Halt()
|
||||||
p.Kill()
|
p.Detach(true)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
fn(p, fixture)
|
fn(p, fixture)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user