Skip to content

cmd/go: add test to ensure the correct line number is displayed when using TB.Helper with race detector #26995

@maxatome

Description

@maxatome

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.TestingAn issue that has been verified to require only test changes, not just a test failure.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions