New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: with race detector on, using TB.Helper yields the wrong line number #26995

Open
maxatome opened this Issue Aug 15, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@maxatome

maxatome commented Aug 15, 2018

Similar problem referenced in #21631

What version of Go are you using (go version)?

go version go1.10.3 freebsd/amd64

go version go1.11rc1 freebsd/amd64

Does this issue reproduce with the latest release?

yes, but a little differently

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/max/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH="/home/max/Projet/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build991380835=/tmp/go-build -gno-record-gcc-switches"

What did you do?

testing_test.go:

package testing_test

import "testing"

type TestingT interface {
	Helper()
	Log(args ...interface{})
}

func directCall(t *testing.T) {
	t.Helper()
	t.Log("directCall")
}

func interfaceTBCall(t testing.TB) {
	t.Helper()
	t.Log("interfaceTBCall")
}

func interfaceCall(t TestingT) {
	t.Helper()
	t.Log("interfaceCall")
}

func TestTesting(t *testing.T) {
	directCall(t)
	interfaceTBCall(t)
	interfaceCall(t)
}

Then

go test -v -race

What did you expect to see?

=== RUN   TestTesting
--- PASS: TestTesting (0.00s)
	testing_test.go:26: directCall
	testing_test.go:27: interfaceTBCall
	testing_test.go:28: interfaceCall
PASS
ok  	_/home/max	1.035s

(in fact the same output as without the -race flag.)

What did you see instead?

With go1.10.3:

=== RUN   TestTesting
--- PASS: TestTesting (0.00s)
	testing_test.go:26: directCall
	testing_test.go:17: interfaceTBCall
	testing_test.go:22: interfaceCall
PASS
ok  	_/home/max	1.035s

With go1.11rc1:

=== RUN   TestTesting
--- PASS: TestTesting (0.00s)
    testing_test.go:26: directCall
    <autogenerated>:1: interfaceTBCall
    <autogenerated>:1: interfaceCall
PASS
ok  	_/home/max	1.074s

@andybons andybons changed the title from testing: with race detector on, using TB.Helper yields the wrong line number to cmd/go: with race detector on, using TB.Helper yields the wrong line number Aug 15, 2018

@andybons

This comment has been minimized.

Member

andybons commented Aug 15, 2018

@andybons andybons added this to the Unplanned milestone Aug 15, 2018

maxatome added a commit to maxatome/go-testdeep that referenced this issue Aug 17, 2018

Work around golang/go#26995 issue
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>

maxatome added a commit to maxatome/go-testdeep that referenced this issue Aug 17, 2018

Work around golang/go#26995 issue
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>

maxatome added a commit to maxatome/go-testdeep that referenced this issue Aug 17, 2018

Work around golang/go#26995 issue
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>

maxatome added a commit to maxatome/go-testdeep that referenced this issue Aug 18, 2018

Work around golang/go#26995 issue
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment