Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.

Commit 62d60c2

Browse files
committed
fix subtest caller pc
1 parent 5a1148d commit 62d60c2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

instrumentation/testing/init.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package testing
33
import (
44
"flag"
55
"reflect"
6-
"runtime"
76
"testing"
87

98
"github.com/undefinedlabs/go-mpatch"
@@ -78,7 +77,7 @@ func PatchTRun() {
7877
}
7978

8079
_, err := mpatch.PatchMethodByReflect(tRunMethod, func(t *testing.T, name string, f func(t *testing.T)) bool {
81-
pc, _, _, _ := runtime.Caller(1)
80+
pc := reflect.ValueOf(f).Pointer()
8281
gT := FromTestingT(t)
8382
return gT.Run(name, func(childT *testing.T) {
8483
addAutoInstrumentedTest(childT)
@@ -103,7 +102,7 @@ func PatchBRun() {
103102
}
104103

105104
_, err := mpatch.PatchMethodByReflect(bRunMethod, func(b *testing.B, name string, f func(b *testing.B)) bool {
106-
pc, _, _, _ := runtime.Caller(1)
105+
pc := reflect.ValueOf(f).Pointer()
107106
return FromTestingB(b).Run(name, func(b *testing.B) {
108107
StartBenchmark(b, pc, f)
109108
})

0 commit comments

Comments
 (0)