Skip to content

Commit 9d89a5e

Browse files
committed
all: update terminology for fuzzing
This change doesn't modify any functionality. It also doesn't update all of the comments and variable names of the internal code, but everything user facing should be correct. Updates #49185 Change-Id: Ia8b2c94b89ba45897c4085ea0c17a3d8896f7ec7 Reviewed-on: https://go-review.googlesource.com/c/go/+/362794 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
1 parent ccd41cc commit 9d89a5e

File tree

11 files changed

+160
-159
lines changed

11 files changed

+160
-159
lines changed

src/cmd/go/alldocs.go

+15-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/test/test.go

+21-22
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ followed by detailed output for each failed package.
6565
'Go test' recompiles each package along with any files with names matching
6666
the file pattern "*_test.go".
6767
These additional files can contain test functions, benchmark functions, fuzz
68-
targets and example functions. See 'go help testfunc' for more.
68+
tests and example functions. See 'go help testfunc' for more.
6969
Each listed package causes the execution of a separate test binary.
7070
Files whose names begin with "_" (including "_test.go") or "." are ignored.
7171
@@ -214,7 +214,7 @@ control the execution of any test:
214214
Run each test, benchmark, and fuzz seed n times (default 1).
215215
If -cpu is set, run n times for each GOMAXPROCS value.
216216
Examples are always run once. -count does not apply to
217-
fuzz targets matched by -fuzz.
217+
fuzz tests matched by -fuzz.
218218
219219
-cover
220220
Enable coverage analysis.
@@ -242,20 +242,19 @@ control the execution of any test:
242242
243243
-cpu 1,2,4
244244
Specify a list of GOMAXPROCS values for which the tests, benchmarks or
245-
fuzz targets should be executed. The default is the current value
246-
of GOMAXPROCS. -cpu does not apply to fuzz targets matched by -fuzz.
245+
fuzz tests should be executed. The default is the current value
246+
of GOMAXPROCS. -cpu does not apply to fuzz tests matched by -fuzz.
247247
248248
-failfast
249249
Do not start new tests after the first test failure.
250250
251251
-fuzz regexp
252-
Run the fuzz target matching the regular expression. When specified,
252+
Run the fuzz test matching the regular expression. When specified,
253253
the command line argument must match exactly one package within the
254-
main module, and regexp must match exactly one fuzz target within
255-
that package. After tests, benchmarks, seed corpora of other fuzz
256-
targets, and examples have completed, the matching target will be
257-
fuzzed. See the Fuzzing section of the testing package documentation
258-
for details.
254+
main module, and regexp must match exactly one fuzz test within
255+
that package. Fuzzing will occur after tests, benchmarks, seed corpora
256+
of other fuzz tests, and examples have completed. See the Fuzzing
257+
section of the testing package documentation for details.
259258
260259
-fuzztime t
261260
Run enough iterations of the fuzz test to take t, specified as a
@@ -269,14 +268,14 @@ control the execution of any test:
269268
same information as the -v flag in a machine-readable format.
270269
271270
-list regexp
272-
List tests, benchmarks, fuzz targets, or examples matching the regular
273-
expression. No tests, benchmarks, fuzz targets, or examples will be run.
271+
List tests, benchmarks, fuzz tests, or examples matching the regular
272+
expression. No tests, benchmarks, fuzz tests, or examples will be run.
274273
This will only list top-level tests. No subtest or subbenchmarks will be
275274
shown.
276275
277276
-parallel n
278277
Allow parallel execution of test functions that call t.Parallel, and
279-
f.Fuzz functions that call t.Parallel when running the seed corpus.
278+
fuzz targets that call t.Parallel when running the seed corpus.
280279
The value of this flag is the maximum number of tests to run
281280
simultaneously.
282281
While fuzzing, the value of this flag is the maximum number of
@@ -291,7 +290,7 @@ control the execution of any test:
291290
(see 'go help build').
292291
293292
-run regexp
294-
Run only those tests, examples, and fuzz targets matching the regular
293+
Run only those tests, examples, and fuzz tests matching the regular
295294
expression. For tests, the regular expression is split by unbracketed
296295
slash (/) characters into a sequence of regular expressions, and each
297296
part of a test's identifier must match the corresponding element in
@@ -468,7 +467,7 @@ A benchmark function is one named BenchmarkXxx and should have the signature,
468467
469468
func BenchmarkXxx(b *testing.B) { ... }
470469
471-
A fuzz target is one named FuzzXxx and should have the signature,
470+
A fuzz test is one named FuzzXxx and should have the signature,
472471
473472
func FuzzXxx(f *testing.F) { ... }
474473
@@ -511,7 +510,7 @@ Here is another example where the ordering of the output is ignored:
511510
512511
The entire test file is presented as the example when it contains a single
513512
example function, at least one other function, type, variable, or constant
514-
declaration, and no fuzz targets or test or benchmark functions.
513+
declaration, and no tests, benchmarks, or fuzz tests.
515514
516515
See the documentation of the testing package for more information.
517516
`,
@@ -1196,8 +1195,8 @@ func declareCoverVars(p *load.Package, files ...string) map[string]*load.CoverVa
11961195
}
11971196

11981197
var noTestsToRun = []byte("\ntesting: warning: no tests to run\n")
1199-
var noTargetsToFuzz = []byte("\ntesting: warning: no targets to fuzz\n")
1200-
var tooManyTargetsToFuzz = []byte("\ntesting: warning: -fuzz matches more than one target, won't fuzz\n")
1198+
var noFuzzTestsToFuzz = []byte("\ntesting: warning: no fuzz tests to fuzz\n")
1199+
var tooManyFuzzTestsToFuzz = []byte("\ntesting: warning: -fuzz matches more than one fuzz test, won't fuzz\n")
12011200

12021201
type runCache struct {
12031202
disableCache bool // cache should be disabled for this run
@@ -1399,11 +1398,11 @@ func (c *runCache) builderRunTest(b *work.Builder, ctx context.Context, a *work.
13991398
if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) {
14001399
norun = " [no tests to run]"
14011400
}
1402-
if bytes.HasPrefix(out, noTargetsToFuzz[1:]) || bytes.Contains(out, noTargetsToFuzz) {
1403-
norun = " [no targets to fuzz]"
1401+
if bytes.HasPrefix(out, noFuzzTestsToFuzz[1:]) || bytes.Contains(out, noFuzzTestsToFuzz) {
1402+
norun = " [no fuzz tests to fuzz]"
14041403
}
1405-
if bytes.HasPrefix(out, tooManyTargetsToFuzz[1:]) || bytes.Contains(out, tooManyTargetsToFuzz) {
1406-
norun = " [will not fuzz, -fuzz matches more than one target]"
1404+
if bytes.HasPrefix(out, tooManyFuzzTestsToFuzz[1:]) || bytes.Contains(out, tooManyFuzzTestsToFuzz) {
1405+
norun = "[-fuzz matches more than one fuzz test, won't fuzz]"
14071406
}
14081407
if len(out) > 0 && !bytes.HasSuffix(out, []byte("\n")) {
14091408
// Ensure that the output ends with a newline before the "ok"

src/cmd/go/testdata/script/test_fuzz.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,34 @@ stdout ok
6060
! stdout ^ok
6161
! stdout 'fatal here'
6262
stdout FAIL
63-
stdout 'f.Fuzz function'
63+
stdout 'fuzz target'
6464

6565
# Test that f.Error within f.Fuzz panics
6666
! go test error_fuzz_fn_fuzz_test.go
6767
! stdout ^ok
6868
! stdout 'error here'
6969
stdout FAIL
70-
stdout 'f.Fuzz function'
70+
stdout 'fuzz target'
7171

7272
# Test that f.Fail within f.Fuzz panics
7373
! go test fail_fuzz_fn_fuzz_test.go
7474
! stdout ^ok
7575
stdout FAIL
76-
stdout 'f.Fuzz function'
76+
stdout 'fuzz target'
7777

7878
# Test that f.Skip within f.Fuzz panics
7979
! go test skip_fuzz_fn_fuzz_test.go
8080
! stdout ^ok
8181
! stdout 'skip here'
8282
stdout FAIL
83-
stdout 'f.Fuzz function'
83+
stdout 'fuzz target'
8484

8585
# Test that f.Skipped within f.Fuzz panics
8686
! go test skipped_fuzz_fn_fuzz_test.go
8787
! stdout ^ok
8888
! stdout 'f.Skipped is'
8989
stdout FAIL
90-
stdout 'f.Fuzz function'
90+
stdout 'fuzz target'
9191
stdout 't.Skipped is false'
9292

9393
# Test that runtime.Goexit within the fuzz function is an error.

src/cmd/go/testdata/script/test_fuzz_match.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ stdout '^ok'
1414
go test -fuzz ThisWillNotMatch -fuzztime 1x standalone_fuzz_test.go
1515
! stdout '^ok.*no tests to run'
1616
stdout '^ok'
17-
stdout 'no targets to fuzz'
17+
stdout 'no fuzz tests to fuzz'
1818

1919
[short] stop
2020

@@ -26,7 +26,7 @@ stdout '^ok'
2626
# Matches no fuzz targets.
2727
go test -run ThisWillNotMatch standalone_fuzz_test.go
2828
stdout '^ok.*no tests to run'
29-
! stdout 'no targets to fuzz'
29+
! stdout 'no fuzz tests to fuzz'
3030

3131
-- standalone_fuzz_test.go --
3232
package standalone_fuzz

src/cmd/go/testdata/script/test_fuzz_multiple.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ go test -fuzz=. -fuzztime=1x ./one
1818

1919
# With fuzzing enabled, at most one target in the same package may match.
2020
! go test -fuzz=. ./two
21-
stdout '^testing: will not fuzz, -fuzz matches more than one target: \[FuzzOne FuzzTwo\]$'
21+
stdout '^testing: will not fuzz, -fuzz matches more than one fuzz test: \[FuzzOne FuzzTwo\]$'
2222
go test -fuzz=FuzzTwo -fuzztime=1x ./two
2323

2424
-- go.mod --

src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
! exists want
1414
! go test -fuzz=. -parallel=1 -fuzztime=110x -fuzzminimizetime=10x -v
1515
stdout 'fuzzing process terminated unexpectedly'
16-
stdout 'Crash written to testdata'
16+
stdout 'Failing input written to testdata'
1717

1818
# Run the fuzz target without fuzzing. The fuzz function is called with the
1919
# crashing input in testdata. The test passes if that input is identical to

src/cmd/go/testdata/script/test_fuzz_seed_corpus.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env GOCACHE=$WORK/cache
66
# and doesn't write anything to testdata/fuzz
77
! go test -fuzz=FuzzWithAdd -run=FuzzWithAdd -fuzztime=1x
88
! stdout ^ok
9-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
9+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
1010
stdout FAIL
1111

1212
# Test that fuzzing a target with a sucess in f.Add and a fuzztime of only
@@ -19,15 +19,15 @@ stdout ok
1919
# and doesn't write anything to testdata/fuzz
2020
! go test -fuzz=FuzzWithTestdata -run=FuzzWithTestdata -fuzztime=1x
2121
! stdout ^ok
22-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
23-
stdout 'found a crash while testing seed corpus entry: FuzzWithTestdata/1'
22+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
23+
stdout 'failure while testing seed corpus entry: FuzzWithTestdata/1'
2424
stdout FAIL
2525

2626
# Test that fuzzing a target with no seed corpus or cache finds a crash, prints
2727
# it, and write it to testdata
2828
! go test -fuzz=FuzzWithNoCache -run=FuzzWithNoCache -fuzztime=1x
2929
! stdout ^ok
30-
stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithNoCache[/\\]'
30+
stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithNoCache[/\\]'
3131
stdout FAIL
3232

3333
# Write a crashing input to the cache
@@ -38,7 +38,7 @@ cp cache-file $GOCACHE/fuzz/example.com/x/FuzzWithCache/1
3838
# and writes this as a "new" crash to testdata/fuzz
3939
! go test -fuzz=FuzzWithCache -run=FuzzWithCache -fuzztime=1x
4040
! stdout ^ok
41-
stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithCache[/\\]'
41+
stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithCache[/\\]'
4242
stdout FAIL
4343

4444
# Write a crashing input to the cache
@@ -52,7 +52,7 @@ cp cache-file-bytes $GOCACHE/fuzz/example.com/x/FuzzWithMinimizableCache/1
5252
stdout 'gathering baseline coverage'
5353
stdout 'got the minimum size!'
5454
stdout 'contains a non-zero byte of length 10'
55-
stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithMinimizableCache[/\\]'
55+
stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithMinimizableCache[/\\]'
5656
stdout FAIL
5757
# Make sure this crash didn't come from fuzzing
5858
# (the log line that states fuzzing began shouldn't have printed)
@@ -70,7 +70,7 @@ go clean -fuzzcache
7070
# the crash and doesn't write anything to testdata/fuzz -fuzztime=1x
7171
! go test -fuzz=FuzzWithAdd -run=None
7272
! stdout ^ok
73-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
73+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
7474
stdout FAIL
7575

7676
# Test that fuzzing a target (with -run=None set) with a sucess in f.Add and a
@@ -83,7 +83,7 @@ stdout ok
8383
# testdata/fuzz prints the crash and doesn't write anything to testdata/fuzz
8484
! go test -fuzz=FuzzWithTestdata -run=None -fuzztime=1x
8585
! stdout ^ok
86-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
86+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
8787
stdout FAIL
8888

8989
# Write a crashing input to the cache
@@ -94,7 +94,7 @@ cp cache-file $GOCACHE/fuzz/example.com/x/FuzzRunNoneWithCache/1
9494
# prints the crash and writes this as a "new" crash to testdata/fuzz
9595
! go test -fuzz=FuzzRunNoneWithCache -run=None -fuzztime=1x
9696
! stdout ^ok
97-
stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzRunNoneWithCache[/\\]'
97+
stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzRunNoneWithCache[/\\]'
9898
stdout FAIL
9999

100100
# Clear the fuzz cache and make sure it's gone
@@ -109,14 +109,14 @@ go clean -fuzzcache
109109
go test -c
110110
! exec ./x.test$GOEXE -test.fuzz=FuzzWithAdd -test.run=FuzzWithAdd -test.fuzztime=1x -test.fuzzcachedir=$WORK/cache
111111
! stdout ^ok
112-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
112+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithAdd[/\\]'
113113
stdout FAIL
114114
stderr warning
115115

116116
go test -c
117117
! exec ./x.test$GOEXE -test.fuzz=FuzzWithTestdata -test.run=FuzzWithTestdata -test.fuzztime=1x -test.fuzzcachedir=$WORK/cache
118118
! stdout ^ok
119-
! stdout 'Crash written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
119+
! stdout 'Failing input written to testdata[/\\]fuzz[/\\]FuzzWithTestdata[/\\]'
120120
stdout FAIL
121121
stderr warning
122122

src/go/doc/example.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ type Example struct {
4444
// identifiers from other packages (or predeclared identifiers, such as
4545
// "int") and the test file does not include a dot import.
4646
// - The entire test file is the example: the file contains exactly one
47-
// example function, zero test, fuzz target, or benchmark function, and at
47+
// example function, zero test, fuzz test, or benchmark function, and at
4848
// least one top-level function, type, variable, or constant declaration
4949
// other than the example function.
5050
func Examples(testFiles ...*ast.File) []*Example {
5151
var list []*Example
5252
for _, file := range testFiles {
53-
hasTests := false // file contains tests, fuzz targets, or benchmarks
53+
hasTests := false // file contains tests, fuzz test, or benchmarks
5454
numDecl := 0 // number of non-import declarations in the file
5555
var flist []*Example
5656
for _, decl := range file.Decls {
@@ -133,7 +133,7 @@ func exampleOutput(b *ast.BlockStmt, comments []*ast.CommentGroup) (output strin
133133
return "", false, false // no suitable comment found
134134
}
135135

136-
// isTest tells whether name looks like a test, example, fuzz target, or
136+
// isTest tells whether name looks like a test, example, fuzz test, or
137137
// benchmark. It is a Test (say) if there is a character after Test that is not
138138
// a lower-case letter. (We don't want Testiness.)
139139
func isTest(name, prefix string) bool {

0 commit comments

Comments
 (0)