From 7628627cb236662002b53686ff0618834a9aa077 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 8 Feb 2023 14:36:47 -0500 Subject: [PATCH] [release-branch.go1.20] cmd/go/internal/test: refresh flagdefs.go and fix test The tests for cmd/go/internal/test were not running at all due to a missed call to m.Run in TestMain. That masked a missing vet analyzer ("timeformat") and a missed update to the generator script in CL 355452. Fixes #58421. Updates #58415. Change-Id: I7b0315952967ca07a866cdaa5903478b2873eb7a Reviewed-on: https://go-review.googlesource.com/c/go/+/466635 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Bryan Mills Run-TryBot: Bryan Mills (cherry picked from commit 910f041ff0cdf90dbcd3bd22a272b9b7205a5add) Reviewed-on: https://go-review.googlesource.com/c/go/+/466855 --- src/cmd/go/internal/test/flagdefs.go | 1 + src/cmd/go/internal/test/flagdefs_test.go | 4 ++++ src/cmd/go/internal/test/genflags.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/internal/test/flagdefs.go b/src/cmd/go/internal/test/flagdefs.go index b91204ee93..3f3709fe7e 100644 --- a/src/cmd/go/internal/test/flagdefs.go +++ b/src/cmd/go/internal/test/flagdefs.go @@ -66,6 +66,7 @@ var passAnalyzersToVet = map[string]bool{ "structtag": true, "testinggoroutine": true, "tests": true, + "timeformat": true, "unmarshal": true, "unreachable": true, "unsafeptr": true, diff --git a/src/cmd/go/internal/test/flagdefs_test.go b/src/cmd/go/internal/test/flagdefs_test.go index 337f136d06..d5facb7161 100644 --- a/src/cmd/go/internal/test/flagdefs_test.go +++ b/src/cmd/go/internal/test/flagdefs_test.go @@ -9,6 +9,7 @@ import ( "cmd/go/internal/test/internal/genflags" "flag" "internal/testenv" + "os" "reflect" "strings" "testing" @@ -16,6 +17,7 @@ import ( func TestMain(m *testing.M) { cfg.SetGOROOT(testenv.GOROOT(nil), false) + os.Exit(m.Run()) } func TestPassFlagToTestIncludesAllTestFlags(t *testing.T) { @@ -48,6 +50,8 @@ func TestPassFlagToTestIncludesAllTestFlags(t *testing.T) { } func TestVetAnalyzersSetIsCorrect(t *testing.T) { + testenv.MustHaveGoBuild(t) // runs 'go tool vet -flags' + vetAns, err := genflags.VetAnalyzers() if err != nil { t.Fatal(err) diff --git a/src/cmd/go/internal/test/genflags.go b/src/cmd/go/internal/test/genflags.go index 8c7554919a..625f94133a 100644 --- a/src/cmd/go/internal/test/genflags.go +++ b/src/cmd/go/internal/test/genflags.go @@ -75,7 +75,7 @@ func testFlags() []string { } switch name { - case "testlogfile", "paniconexit0", "fuzzcachedir", "fuzzworker": + case "testlogfile", "paniconexit0", "fuzzcachedir", "fuzzworker", "gocoverdir": // These flags are only for use by cmd/go. default: names = append(names, name) -- 2.48.1