cmd/go: fix TestScript/vet_flags

Test caching can cause an incorrect test failure when the vet step result
is reused, leading to not printing a vet command line at all.
Avoid that with -a (we are also using -n so no real work is done).

Fixes one failing case in 'go test cmd/go' on my Mac.

Change-Id: I028284436b1ecc77145c886db902845b524f4b97
Reviewed-on: https://go-review.googlesource.com/c/go/+/718181
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
This commit is contained in:
Russ Cox 2025-11-05 13:49:48 -05:00 committed by Gopher Robot
parent a8fb94969c
commit a494a26bc2

View file

@ -20,7 +20,8 @@ stderr '-unsafeptr'
! stderr '-unsafeptr=false'
# -unreachable is disabled during test but on during plain vet.
go test -n runtime
# The -a makes sure the vet result is not cached, or else we won't print the command line.
go test -a -n runtime
stderr '-unreachable=false'
# A flag terminator should be allowed before the package list.
@ -63,16 +64,16 @@ go test -n -vet= -run=none .
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# "go test" on a standard package should by default disable an explicit list.
go test -n -run=none encoding/binary
go test -a -n -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
go test -n -vet= -run=none encoding/binary
go test -a -n -vet= -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# Both should allow users to override via the -vet flag.
go test -n -vet=unreachable -run=none .
go test -a -n -vet=unreachable -run=none .
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
go test -n -vet=unreachable -run=none encoding/binary
go test -a -n -vet=unreachable -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
-- go.mod --