From 4fb2f3ca22de92e7ad6137fb988dcc1cd4449ceb Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Mon, 5 Oct 2020 14:24:21 -0400 Subject: [dev.fuzz] testing: panic if certain testing.F functions are called in Fuzz func Change-Id: I8ee513b2b157e6033d4bc9607d0e65f42bd6801f Reviewed-on: https://go-review.googlesource.com/c/go/+/259657 Trust: Katie Hockman Trust: Jay Conrod Run-TryBot: Katie Hockman TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- src/testing/fuzz.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/testing/fuzz.go') diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index 6f985c7c38..01895e8d7d 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -87,11 +87,16 @@ func (f *F) Fuzz(ff interface{}) { } if err != nil { t.Fail() - t.output = []byte(fmt.Sprintf(" panic: %s\n", err)) + t.output = []byte(fmt.Sprintf(" %s", err)) } f.setRan() + f.inFuzzFn = false t.signal <- true // signal that the test has finished }() + // TODO(katiehockman, jayconrod): consider replacing inFuzzFn with + // general purpose flag that checks whether specific methods can be + // called. + f.inFuzzFn = true fn(t, b) t.finished = true } -- cgit v1.3-5-g9baa