]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.fuzz] cmd/go/internal/cfg: enable "gofuzzbeta" tag by default
authorJay Conrod <jayconrod@google.com>
Tue, 11 May 2021 22:05:43 +0000 (18:05 -0400)
committerJay Conrod <jayconrod@google.com>
Wed, 19 May 2021 18:17:13 +0000 (18:17 +0000)
This lets users check in fuzz targets for use with this branch without
breaking the build for developers using a regular version of Go.

Before we merge this branch to master, this CL should be reverted. At
that point, users should change the tag to go1.18 (or whichever
version we land on).

Change-Id: I0e21a21e415e4fb7c599abe11e61de754c74a3d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/319872
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/testdata/script/test_fuzz_tag.txt [new file with mode: 0644]

index b47eb812b59ea54d6911fa687ba01fbf6469bcb6..21a56d6df67ef088cbbdae14b79b0618792f3f93 100644 (file)
@@ -58,6 +58,10 @@ var (
 
 func defaultContext() build.Context {
        ctxt := build.Default
+
+       // TODO(b/187972950): remove this tag before merging to master.
+       ctxt.BuildTags = []string{"gofuzzbeta"}
+
        ctxt.JoinPath = filepath.Join // back door to say "do not use go command"
 
        ctxt.GOROOT = findGOROOT()
diff --git a/src/cmd/go/testdata/script/test_fuzz_tag.txt b/src/cmd/go/testdata/script/test_fuzz_tag.txt
new file mode 100644 (file)
index 0000000..07ed5d6
--- /dev/null
@@ -0,0 +1,31 @@
+# Check that the gofuzzbeta tag is enabled by default and can be disabled.
+# TODO(jayconrod,katiehockman): before merging to master, restore the old
+# default and delete this test.
+
+[short] skip
+
+go test -list=.
+stdout Test
+stdout Fuzz
+
+go test -tags=
+
+-- go.mod --
+module fuzz
+
+go 1.17
+-- fuzz_test.go --
+// +build gofuzzbeta
+
+package fuzz
+
+import "testing"
+
+func Fuzz(f *testing.F) {
+       f.Add([]byte(nil))
+       f.Fuzz(func(*testing.T, []byte) {})
+}
+
+func Test(*testing.T) {}
+-- empty_test.go --
+package fuzz