Skip to content
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

testing: with race detector on, using TB.Helper yields the wrong line number #21631

Closed
cespare opened this issue Aug 25, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@cespare
Copy link
Contributor

commented Aug 25, 2017

Using go1.9 linux/amd64.

If you call testing.TB.Helper (i.e., through the interface), it prints an autogenerated line number when running with -race:

package main

import (
	"testing"
)

func TestFoo(t *testing.T) {
	f(t)
	g(t)
}

func f(tb testing.TB) {
	tb.Helper()
	tb.Error("asdf")
}

func g(t *testing.T) {
	t.Helper()
	t.Error("asdf")
}

gives

$ go test x_test.go
--- FAIL: TestFoo (0.00s)
        x_test.go:8: asdf
        x_test.go:9: asdf
FAIL
FAIL    command-line-arguments  0.001s
$ go test -race x_test.go
--- FAIL: TestFoo (0.00s)
        <autogenerated>:1: asdf
        x_test.go:9: asdf
FAIL
FAIL    command-line-arguments  0.005s

Bug pointed out on golang-nuts by @lukasmalkmus.

@cespare cespare changed the title testing: with race detector on, calling TB.Helper shows the wrong line number testing: with race detector on, using TB.Helper yields the wrong line number Aug 25, 2017

@cespare cespare added this to the Go1.10 milestone Aug 25, 2017

@odeke-em

This comment has been minimized.

Copy link
Member

commented Aug 27, 2017

/cc @josharian @mdempsky @griesemer and all of the compiler squad

@agnivade

This comment has been minimized.

Copy link
Member

commented Oct 12, 2017

This is now fixed in latest master. Not sure which commit though 😕 I just tried on the latest master and it worked.

@cespare

This comment has been minimized.

Copy link
Contributor Author

commented Oct 31, 2017

A bisect pointed, unsurprisingly, at e972095.

Thanks @aclements!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.