diff --git a/panicwrap.go b/panicwrap.go index 1478244..f83d43c 100644 --- a/panicwrap.go +++ b/panicwrap.go @@ -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 diff --git a/panicwrap_test.go b/panicwrap_test.go index 8910a7f..f0eaac8 100644 --- a/panicwrap_test.go +++ b/panicwrap_test.go @@ -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 @@ -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()