@@ -49,6 +49,44 @@ helperfuncs_test.go:60: 10
49
49
}
50
50
}
51
51
52
+ func TestTBHelperLineNumer (t * T ) {
53
+ var buf bytes.Buffer
54
+ ctx := newTestContext (1 , newMatcher (regexp .MatchString , "" , "" ))
55
+ t1 := & T {
56
+ common : common {
57
+ signal : make (chan bool ),
58
+ w : & buf ,
59
+ },
60
+ context : ctx ,
61
+ }
62
+ t1 .Run ("Test" , func (t * T ) {
63
+ helperA := func (t * T ) {
64
+ t .Helper ()
65
+ t .Run ("subtest" , func (t * T ) {
66
+ t .Helper ()
67
+ t .Fatal ("fatal error message" )
68
+ })
69
+ }
70
+ helperA (t )
71
+ })
72
+
73
+ want := `--- FAIL: Test (?s)
74
+ --- FAIL: Test/subtest (?s)
75
+ helper_test.go:70: fatal error message
76
+ `
77
+ lines := strings .Split (buf .String (), "\n " )
78
+ durationRE := regexp .MustCompile (`\(.*\)$` )
79
+ for i , line := range lines {
80
+ line = strings .TrimSpace (line )
81
+ line = durationRE .ReplaceAllString (line , "(?s)" )
82
+ lines [i ] = line
83
+ }
84
+ got := strings .Join (lines , "\n " )
85
+ if got != want {
86
+ t .Errorf ("got output:\n \n %v\n want:\n \n %v" , got , want )
87
+ }
88
+ }
89
+
52
90
func TestTBHelperParallel (t * T ) {
53
91
var buf bytes.Buffer
54
92
ctx := newTestContext (1 , newMatcher (regexp .MatchString , "" , "" ))
0 commit comments