Skip to content

Commit

Permalink
Merge #59189
Browse files Browse the repository at this point in the history
59189: leaktest: don't swallow stacks for panics r=knz,irfansharif a=tbg

leaktest recovers panics, but in translating them into a `t.Fatal` it
failed to report the stack trace.

Release note: None


Co-authored-by: Tobias Grieger <[email protected]>
  • Loading branch information
craig[bot] and tbg committed Jan 21, 2021
2 parents fbf596c + d0103b7 commit 3d9d632
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/util/leaktest/leaktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package leaktest
import (
"fmt"
"runtime"
"runtime/debug"
"sort"
"strings"
"sync/atomic"
Expand Down Expand Up @@ -99,7 +100,12 @@ func AfterTest(t testing.TB) func() {
// If there was a panic, "leaked" goroutines are expected.
if r := recover(); r != nil {
atomic.StoreUint32(&leakDetectorDisabled, 1)
t.Fatalf("panic: %+v", r)
// NB: we don't want to re-panic here, for the Go test
// harness will not recover that for us. Instead, it will
// stop running the tests, but we are deciding here to fail
// only that one test but keep going otherwise.
// We need to explicitly print the stack trace though.
t.Fatalf("%v\n%s", r, debug.Stack())
return
}

Expand Down

0 comments on commit 3d9d632

Please sign in to comment.