Skip to content

Commit b00dcf0

Browse files
committed
testing: fix Helper line number change
parent's helperNames has not been set when frameSkip called, moving helperNames initilazing to frameSkip. Fixes #44887 Change-Id: I5107c5951033e5e47d1ac441eac3ba5344a7bdc0
1 parent a61524d commit b00dcf0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/testing/testing.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ func (c *common) frameSkip(skip int) runtime.Frame {
509509
}
510510
return prevFrame
511511
}
512+
if c.helperNames == nil {
513+
c.helperNames = make(map[string]struct{})
514+
for pc := range c.helperPCs {
515+
c.helperNames[pcToName(pc)] = struct{}{}
516+
}
517+
}
512518
if _, ok := c.helperNames[frame.Function]; !ok {
513519
// Found a frame that wasn't inside a helper function.
514520
return frame
@@ -521,14 +527,6 @@ func (c *common) frameSkip(skip int) runtime.Frame {
521527
// and inserts the final newline if needed and indentation spaces for formatting.
522528
// This function must be called with c.mu held.
523529
func (c *common) decorate(s string, skip int) string {
524-
// If more helper PCs have been added since we last did the conversion
525-
if c.helperNames == nil {
526-
c.helperNames = make(map[string]struct{})
527-
for pc := range c.helperPCs {
528-
c.helperNames[pcToName(pc)] = struct{}{}
529-
}
530-
}
531-
532530
frame := c.frameSkip(skip)
533531
file := frame.File
534532
line := frame.Line

0 commit comments

Comments
 (0)