if f.inFuzzFn {
panic("testing: f.Cleanup was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Cleanup(fn)
}
if f.inFuzzFn {
panic("testing: f.Error was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Error(args...)
}
if f.inFuzzFn {
panic("testing: f.Errorf was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Errorf(format, args...)
}
if f.inFuzzFn {
panic("testing: f.Fail was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Fail()
}
if f.inFuzzFn {
panic("testing: f.FailNow was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.FailNow()
}
if f.inFuzzFn {
panic("testing: f.Fatal was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Fatal(args...)
}
if f.inFuzzFn {
panic("testing: f.Fatalf was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Fatalf(format, args...)
}
if f.inFuzzFn {
panic("testing: f.Helper was called inside the f.Fuzz function")
}
- f.common.Helper()
+
+ // common.Helper is inlined here.
+ // If we called it, it would mark F.Helper as the helper
+ // instead of the caller.
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ if f.helperPCs == nil {
+ f.helperPCs = make(map[uintptr]struct{})
+ }
+ // repeating code from callerName here to save walking a stack frame
+ var pc [1]uintptr
+ n := runtime.Callers(2, pc[:]) // skip runtime.Callers + Helper
+ if n == 0 {
+ panic("testing: zero callers found")
+ }
+ if _, found := f.helperPCs[pc[0]]; !found {
+ f.helperPCs[pc[0]] = struct{}{}
+ f.helperNames = nil // map will be recreated next time it is needed
+ }
}
// Skip is equivalent to Log followed by SkipNow.
if f.inFuzzFn {
panic("testing: f.Skip was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Skip(args...)
}
if f.inFuzzFn {
panic("testing: f.SkipNow was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.SkipNow()
}
if f.inFuzzFn {
panic("testing: f.Skipf was called inside the f.Fuzz function")
}
+ f.common.Helper()
f.common.Skipf(format, args...)
}
if f.inFuzzFn {
panic("testing: f.TempDir was called inside the f.Fuzz function")
}
+ f.common.Helper()
return f.common.TempDir()
}