aboutsummaryrefslogtreecommitdiff
path: root/src/testing/fuzz.go
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2020-10-05 14:24:21 -0400
committerFilippo Valsorda <filippo@golang.org>2020-12-04 19:17:29 +0100
commit4fb2f3ca22de92e7ad6137fb988dcc1cd4449ceb (patch)
treef8c95cb6134025ac0883a2da6a15b3727ca7105b /src/testing/fuzz.go
parentaea29a9016cb5c3e160f94e6a95b197407de8c2c (diff)
downloadgo-4fb2f3ca22de92e7ad6137fb988dcc1cd4449ceb.tar.xz
[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 <katie@golang.org> Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/testing/fuzz.go')
-rw-r--r--src/testing/fuzz.go7
1 files changed, 6 insertions, 1 deletions
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
}