summaryrefslogtreecommitdiff
path: root/src/go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go')
-rw-r--r--src/go/build/deps_test.go5
-rw-r--r--src/go/doc/example.go16
-rw-r--r--src/go/doc/example_test.go6
3 files changed, 18 insertions, 9 deletions
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index cbc77cfe72..a9939dfcf3 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -513,7 +513,10 @@ var depsRules = `
FMT, flag, runtime/debug, runtime/trace, internal/sysinfo, math/rand
< testing;
- internal/testlog, runtime/pprof, regexp
+ FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256
+ < internal/fuzz;
+
+ internal/fuzz, internal/testlog, runtime/pprof, regexp
< testing/internal/testdeps;
OS, flag, testing, internal/cfg
diff --git a/src/go/doc/example.go b/src/go/doc/example.go
index 274000cecb..fbbd846354 100644
--- a/src/go/doc/example.go
+++ b/src/go/doc/example.go
@@ -44,13 +44,13 @@ type Example struct {
// identifiers from other packages (or predeclared identifiers, such as
// "int") and the test file does not include a dot import.
// - The entire test file is the example: the file contains exactly one
-// example function, zero test or benchmark functions, and at least one
-// top-level function, type, variable, or constant declaration other
-// than the example function.
+// example function, zero test, fuzz target, or benchmark function, and at
+// least one top-level function, type, variable, or constant declaration
+// other than the example function.
func Examples(testFiles ...*ast.File) []*Example {
var list []*Example
for _, file := range testFiles {
- hasTests := false // file contains tests or benchmarks
+ hasTests := false // file contains tests, fuzz targets, or benchmarks
numDecl := 0 // number of non-import declarations in the file
var flist []*Example
for _, decl := range file.Decls {
@@ -64,7 +64,7 @@ func Examples(testFiles ...*ast.File) []*Example {
}
numDecl++
name := f.Name.Name
- if isTest(name, "Test") || isTest(name, "Benchmark") {
+ if isTest(name, "Test") || isTest(name, "Benchmark") || isTest(name, "Fuzz") {
hasTests = true
continue
}
@@ -133,9 +133,9 @@ func exampleOutput(b *ast.BlockStmt, comments []*ast.CommentGroup) (output strin
return "", false, false // no suitable comment found
}
-// isTest tells whether name looks like a test, example, or benchmark.
-// It is a Test (say) if there is a character after Test that is not a
-// lower-case letter. (We don't want Testiness.)
+// isTest tells whether name looks like a test, example, fuzz target, or
+// benchmark. It is a Test (say) if there is a character after Test that is not
+// a lower-case letter. (We don't want Testiness.)
func isTest(name, prefix string) bool {
if !strings.HasPrefix(name, prefix) {
return false
diff --git a/src/go/doc/example_test.go b/src/go/doc/example_test.go
index cf1b702549..21b71290f7 100644
--- a/src/go/doc/example_test.go
+++ b/src/go/doc/example_test.go
@@ -307,6 +307,9 @@ func (X) TestBlah() {
func (X) BenchmarkFoo() {
}
+func (X) FuzzFoo() {
+}
+
func Example() {
fmt.Println("Hello, world!")
// Output: Hello, world!
@@ -326,6 +329,9 @@ func (X) TestBlah() {
func (X) BenchmarkFoo() {
}
+func (X) FuzzFoo() {
+}
+
func main() {
fmt.Println("Hello, world!")
}