From: Quan Tong Date: Mon, 6 Nov 2023 02:17:02 +0000 (+0700) Subject: cmd/go: ensure the correct line number is displayed when using TB.Helper X-Git-Tag: go1.23rc1~1368 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3e789713132be993e74b81e821a4485e83533d61;p=gostls13.git cmd/go: ensure the correct line number is displayed when using TB.Helper Fixes #26995 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-race,gotip-linux-386-longtest,gotip-windows-amd64-longtest Change-Id: If3b68002d205fe985a692b69f5d7e0d2f20a7bd6 Reviewed-on: https://go-review.googlesource.com/c/go/+/540016 TryBot-Bypass: Bryan Mills Reviewed-by: Cherry Mui Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills --- diff --git a/src/cmd/go/testdata/script/test_race_issue26995.txt b/src/cmd/go/testdata/script/test_race_issue26995.txt new file mode 100644 index 0000000000..f40fb46f32 --- /dev/null +++ b/src/cmd/go/testdata/script/test_race_issue26995.txt @@ -0,0 +1,42 @@ +[short] skip +[!race] skip + +go test -v -race +stdout 'testing_test.go:26: directCall' +stdout 'testing_test.go:27: interfaceTBCall' +stdout 'testing_test.go:28: interfaceCall' + +-- go.mod -- +module 26995-TBHelper-line-number + +go 1.21 +-- 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) +}