go-errors / errors

errors with stacktraces for go
https://godoc.org/github.com/go-errors/errors
MIT License
921 stars 93 forks source link

Make tests succeed #17

Closed gabrielf closed 6 years ago

gabrielf commented 6 years ago

So the tests have always failed on my machine because this package's stack trace format is not the same as debug.Stack()'s format. I don't know if the format used by debug.Stack() has changed in some go version and that's why the tests are failing. I also don't know if having the same format as debug.Stack() is a design goal or even desirable.

I know that I prefer this package's stack trace format over debug.Stack() since it puts more emphasis on the file and line number which is what I use the most when dealing with stack traces.

// go-errors stack trace
/Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:22 (0x10f8568)
        TestStackFormat.func1: e, expected, d := Errorf("hi"), callers(), debug.Stack()
    /usr/local/Cellar/go/1.9.4/libexec/src/runtime/asm_amd64.s:509 (0x105438b)
        call32: CALLFN(·call32, 32)
    /usr/local/Cellar/go/1.9.4/libexec/src/runtime/panic.go:491 (0x1029703)
        gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
    /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:247 (0x10f7029)
        c: panic('a')
    /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:243 (0x10f6fe0)
        b: c()
    /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:238 (0x10f6f9a)
        a: b(5)
    /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:44 (0x10f5c78)
        TestStackFormat: a()
    /usr/local/Cellar/go/1.9.4/libexec/src/testing/testing.go:746 (0x10b8150)
        tRunner: fn(t)
    /usr/local/Cellar/go/1.9.4/libexec/src/runtime/asm_amd64.s:2337 (0x1056b61)
        goexit: BYTE    $0x90   // NOP

// debug.Stack() stack trace
goroutine 5 [running]:
    runtime/debug.Stack(0xc4200aa1a0, 0x9, 0x32)
        /usr/local/Cellar/go/1.9.4/libexec/src/runtime/debug/stack.go:24 +0xa7
    github.com/go-errors/errors.TestStackFormat.func1(0xc4200a40f0)
        /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:22 +0x11f
    panic(0x110fd40, 0x1158b58)
        /usr/local/Cellar/go/1.9.4/libexec/src/runtime/panic.go:491 +0x283
    github.com/go-errors/errors.c()
        /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:247 +0x39
    github.com/go-errors/errors.b(0x5)
        /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:243 +0x20
    github.com/go-errors/errors.a(0x8, 0x1149130)
        /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:238 +0x2a
    github.com/go-errors/errors.TestStackFormat(0xc4200a40f0)
        /Users/john.doe/go/src/github.com/go-errors/errors/error_test.go:44 +0x48
    testing.tRunner(0xc4200a40f0, 0x1149138)
        /usr/local/Cellar/go/1.9.4/libexec/src/testing/testing.go:746 +0xd0
    created by testing.(*T).Run
        /usr/local/Cellar/go/1.9.4/libexec/src/testing/testing.go:789 +0x2de
ConradIrwin commented 6 years ago

thank you!