From 49d48a0b4c6359517e62484df4714bf353c45816 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Fri, 11 Mar 2022 14:59:02 -0800 Subject: [PATCH] go/analysis/passes/composite: allow InternalFuzzTarget Add InternalFuzzTarget to the allowlist for the composites analyzer. Other testing-internal struct types produced by the testmain generator are already in there. Fixes golang/go#51623 Change-Id: Ibf91d476ea781c97835157973efc97ce0f987665 Reviewed-on: https://go-review.googlesource.com/c/tools/+/391875 Reviewed-by: Robert Findley Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Gopher Robot gopls-CI: kokoro Trust: Jamal Carvalho Trust: Michael Matloob --- .../composite/testdata/src/a/a_fuzz_test.go | 16 ++++++++++++++++ go/analysis/passes/composite/whitelist.go | 9 +++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 go/analysis/passes/composite/testdata/src/a/a_fuzz_test.go diff --git a/go/analysis/passes/composite/testdata/src/a/a_fuzz_test.go b/go/analysis/passes/composite/testdata/src/a/a_fuzz_test.go new file mode 100644 index 00000000000..20b652e88dd --- /dev/null +++ b/go/analysis/passes/composite/testdata/src/a/a_fuzz_test.go @@ -0,0 +1,16 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.18 +// +build go1.18 + +package a + +import "testing" + +var fuzzTargets = []testing.InternalFuzzTarget{ + {"Fuzz", Fuzz}, +} + +func Fuzz(f *testing.F) {} diff --git a/go/analysis/passes/composite/whitelist.go b/go/analysis/passes/composite/whitelist.go index 1e5f5fd20b5..f84c1871d7d 100644 --- a/go/analysis/passes/composite/whitelist.go +++ b/go/analysis/passes/composite/whitelist.go @@ -26,9 +26,10 @@ var unkeyedLiteral = map[string]bool{ "unicode.Range16": true, "unicode.Range32": true, - // These three structs are used in generated test main files, + // These four structs are used in generated test main files, // but the generator can be trusted. - "testing.InternalBenchmark": true, - "testing.InternalExample": true, - "testing.InternalTest": true, + "testing.InternalBenchmark": true, + "testing.InternalExample": true, + "testing.InternalTest": true, + "testing.InternalFuzzTarget": true, }