]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: ensure the correct line number is displayed when using TB.Helper
authorQuan Tong <quantonganh@gmail.com>
Mon, 6 Nov 2023 02:17:02 +0000 (09:17 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 26 Jan 2024 17:19:18 +0000 (17:19 +0000)
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 <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/testdata/script/test_race_issue26995.txt [new file with mode: 0644]

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 (file)
index 0000000..f40fb46
--- /dev/null
@@ -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)
+}