Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uptesting: when TB is embedded in an interface, TB.Helper yields the wrong line number #26121
Comments
This comment has been minimized.
This comment has been minimized.
There may not be any reasonable way to fix this. t.Helper just looks for its caller, but when you embed testing.TB there is a wrapper function in the call stack. |
This comment has been minimized.
This comment has been minimized.
There was discussion of eliding wrapper functions from runtime.Callers. I don’t have an issue number handy, though. If we decided not to do that, we could add something to the stack frame indicating that it is a wrapper and skip over it here. |
This comment has been minimized.
This comment has been minimized.
Thank you for reporting this issue @thatguystone and for the patience! This issue was fixed in December 2018 for Go1.12 by @randall77's commit 69c2c56 aka CL https://go-review.googlesource.com/c/152537, running your repro on Go1.13 properly produces $ go test
--- FAIL: TestLineNumber (0.00s)
foo_test.go:27: fail
FAIL
exit status 1
FAIL github.com/odeke-em/bugs/golang/26121 0.005s |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build868942347=/tmp/go-build -gno-record-gcc-switches"
What did you do?
What did you expect to see?
What did you see instead?