summaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/test
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-10-28 15:00:33 -0400
committerBryan C. Mills <bcmills@google.com>2021-10-28 20:43:02 +0000
commite741e2fe0e51840b16bfc84d8daaba7670e7aac9 (patch)
tree65f5efb6f05d5b511099b0c93c5dfc03ca09b4d2 /src/cmd/go/internal/test
parent834e36ec778c11b068a2d5354343d4668e5a9ceb (diff)
downloadgo-git-e741e2fe0e51840b16bfc84d8daaba7670e7aac9.tar.gz
cmd/go: consolidate fuzz-support checks
We had been repeating conditions for specific platforms and architectures to gate fuzzing tests, but the more of those tests we add the more we will have to update if the set of supported platforms and archictures expands over time. We also ought to provide a friendlier error message when 'go test -fuzz' is used on non-supported platforms. This change adds predicates in cmd/internal/sys, which already contains similar predicates for related functionality (such as the race detector), and uses those predicates in 'go test' and TestScript. For #48495 Change-Id: If24c3997aeb4d201258e21e5b6cf4f7c08fbadd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/359481 Trust: Bryan C. Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/cmd/go/internal/test')
-rw-r--r--src/cmd/go/internal/test/test.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index ea1d4ff20e..0806d29f21 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -31,9 +31,10 @@ import (
"cmd/go/internal/lockedfile"
"cmd/go/internal/modload"
"cmd/go/internal/search"
+ "cmd/go/internal/str"
"cmd/go/internal/trace"
"cmd/go/internal/work"
- "cmd/go/internal/str"
+ "cmd/internal/sys"
"cmd/internal/test2json"
)
@@ -651,8 +652,13 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
if testO != "" && len(pkgs) != 1 {
base.Fatalf("cannot use -o flag with multiple packages")
}
- if testFuzz != "" && len(pkgs) != 1 {
- base.Fatalf("cannot use -fuzz flag with multiple packages")
+ if testFuzz != "" {
+ if !sys.FuzzSupported(cfg.Goos, cfg.Goarch) {
+ base.Fatalf("-fuzz flag is not supported on %s/%s", cfg.Goos, cfg.Goarch)
+ }
+ if len(pkgs) != 1 {
+ base.Fatalf("cannot use -fuzz flag with multiple packages")
+ }
}
if testProfile() != "" && len(pkgs) != 1 {
base.Fatalf("cannot use %s flag with multiple packages", testProfile())