Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion panicwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func trackPanic(r io.Reader, w io.Writer, dur time.Duration, result chan<- strin
panicBuf := new(bytes.Buffer)
panicHeaders := [][]byte{
[]byte("panic:"),
[]byte("fatal error: fault"),
[]byte("fatal error:"),
}
panicType := -1

Expand Down
38 changes: 38 additions & 0 deletions panicwrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ func TestHelperProcess(*testing.T) {
panic("I AM REAL!")
}

os.Exit(exitStatus)
case "fatal":
exitStatus, err := BasicWrap(panicHandler)

if err != nil {
fmt.Fprintf(os.Stderr, "wrap error: %s", err)
os.Exit(1)
}

if exitStatus < 0 {
// force a concurrent map error
badmap := make(map[int]int)
go func() {
for {
badmap[0] = 0
}
}()
for {
badmap[0] = 0
}
}

os.Exit(exitStatus)
case "panic":
hidePanic := false
Expand Down Expand Up @@ -303,6 +325,22 @@ func TestPanicWrap_panicLong(t *testing.T) {
}
}

func TestPanicWrap_fatal(t *testing.T) {
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)

p := helperProcess("fatal")
p.Stdout = stdout
p.Stderr = stderr
if err := p.Run(); err != nil {
t.Fatalf("err: %s", err)
}

if wrapRe.FindString(stdout.String()) == "" {
t.Fatalf("didn't wrap: %#v", stdout.String())
}
}

func TestPanicWrap_panicBoundary(t *testing.T) {
// TODO(mitchellh): panics are currently lost on boundaries
t.SkipNow()
Expand Down