jacobsa/ogletest

Print nicer output in the event of a panic

Closed this issue · 0 comments

Currently there's a lot of junk at the top of the stack that should be cut out. For example, this is what the output of oglemock's integration test looks like at commit f4fe056d216875f2007feafb123fd1134aed382b:

[ RUN      ] IntegrationTest.ZeroValuesForScalars
value.go:1406:
panic: reflect: call of reflect.Value.Type on zero Value

/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:68 (0x81d15)
    com/jacobsa/ogletest._func_001: "panic: %v\n\n%s", r, debug.Stack())
/Users/jacobsa/go/root/src/pkg/runtime/proc.c:1386 (0x10c2b)
    panic: reflect·call(d->fn, d->args, d->siz);
/Users/jacobsa/go/root/src/pkg/reflect/value.go:1406 (0x8acaf)
    Value.Type: panic(&ValueError{"reflect.Value.Type", Invalid})
/Users/jacobsa/go/clients/src/github.com/jacobsa/oglemock/sample/mock_io/mock_io.go:71 (0x8f2bf)
    com/jacobsa/oglemock/sample/mock_io.(*mockReader).Read: if v.Type() != reflect.TypeOf(o1) {
/Users/jacobsa/go/clients/src/github.com/jacobsa/oglemock/integration_test.go:51 (0x33983)
    com/jacobsa/oglemock_test.(*IntegrationTest).ZeroValuesForScalars: n, err := t.reader.Read([]uint8{})
/Users/jacobsa/go/root/src/pkg/reflect/value.go:517 (0x87322)
    Value.call: call(fn, unsafe.Pointer(ptr), uint32(size))
/Users/jacobsa/go/root/src/pkg/reflect/value.go:330 (0x86115)
    Value.Call: return v.call("Call", in)
/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:215 (0x817a0)
    com/jacobsa/ogletest.runMethodIfExists: method.Call(argVals)
/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:80 (0x8048a)
    com/jacobsa/ogletest.runTest: runMethodIfExists(suiteInstance, method.Name)
/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:150 (0x80cde)
    com/jacobsa/ogletest.runTestsInternal: failures := runTest(suite, method)
/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:109 (0x81e4e)
    com/jacobsa/ogletest._func_002: runTestsOnce.Do(func() { runTestsInternal(t) })
/Users/jacobsa/go/root/src/pkg/sync/once.go:40 (0x5316a)
    (*Once).Do: f()
/Users/jacobsa/go/clients/src/github.com/jacobsa/ogletest/run_tests.go:109 (0x80555)
    com/jacobsa/ogletest.RunTests: runTestsOnce.Do(func() { runTestsInternal(t) })
/Users/jacobsa/go/clients/src/github.com/jacobsa/oglemock/return_test.go:35 (0x36553)
    com/jacobsa/oglemock_test.TestOgletest: func TestOgletest(t *testing.T) { RunTests(t) }
/Users/jacobsa/go/root/src/pkg/testing/testing.go:226 (0x20005)
    tRunner: test.F(t)
/Users/jacobsa/go/root/src/pkg/runtime/proc.c:258 (0xedcd)
    goexit: runtime·goexit(void)


[  FAILED  ] IntegrationTest.ZeroValuesForScalars