Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go/internal/test: stale flagdefs.go not detected by tests #58415

Closed
empire opened this issue Feb 8, 2023 · 6 comments
Closed

cmd/go/internal/test: stale flagdefs.go not detected by tests #58415

empire opened this issue Feb 8, 2023 · 6 comments
Assignees
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@empire
Copy link
Contributor

empire commented Feb 8, 2023

What version of Go are you using (go version)?

$ go version # installed Go
go version go1.19.5 darwin/arm64
$ go version # built Go
go version devel go1.21-1a09d57de5 Wed Feb 8 14:52:12 2023 +0000 darwin/arm64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/hossein/Library/Caches/go-build"
GOENV="/Users/hossein/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hossein/.local/share/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="gitlab.snapp.ir"
GOOS="darwin"
GOPATH="/Users/hossein/.local/share/go"
GOPRIVATE=""
GOPROXY="https://repo.snapp.tech/repository/goproxy/,goproxy.cn,goproxy.io,direct"
GOROOT="/opt/homebrew/Cellar/go/1.19.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hossein/Projects/github.com/golang/go/src/cmd/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/28/0tv7m8993k3859p1zrmyr0th0000gn/T/go-build4070024279=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In order to implement #37708, I ran the following command to generate the needed files, but the command also changed unrelated lines. This behavior is strange, so I filled this issue based on @ianlancetaylor 's feedback.

The output remains the same when using the built version of Go.

cd src/cmd/go/internal/test
go generate ./...
git diff Output
$ git diff
diff --git a/src/cmd/go/internal/test/flagdefs.go b/src/cmd/go/internal/test/flagdefs.go
index 1e0772fe9c..93681498cb 100644
--- a/src/cmd/go/internal/test/flagdefs.go
+++ b/src/cmd/go/internal/test/flagdefs.go
@@ -23,6 +23,7 @@ var passFlagToTest = map[string]bool{
 	"fuzz":                 true,
 	"fuzzminimizetime":     true,
 	"fuzztime":             true,
+	"gocoverdir":           true,
 	"list":                 true,
 	"memprofile":           true,
 	"memprofilerate":       true,
@@ -50,6 +51,7 @@ var passAnalyzersToVet = map[string]bool{
 	"cgocall":          true,
 	"composites":       true,
 	"copylocks":        true,
+	"directive":        true,
 	"errorsas":         true,
 	"framepointer":     true,
 	"httpresponse":     true,
@@ -67,6 +69,7 @@ var passAnalyzersToVet = map[string]bool{
 	"structtag":        true,
 	"testinggoroutine": true,
 	"tests":            true,
+	"timeformat":       true,
 	"unmarshal":        true,
 	"unreachable":      true,
 	"unsafeptr":        true,

I ran the following command to generate the alldocs.go content. When using the built Go command, everything seems fine, but when using the installed Go command, non-related lines are also changed.

cd src/cmd/go
./mkalldocs.sh
git diff Output
$ git diff
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 84afcab7a0..a3c1fecb91 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -97,13 +97,12 @@
 // ends with a slash or backslash, then any resulting executables
 // will be written to that directory.
 //
+// The -i flag installs the packages that are dependencies of the target.
+// The -i flag is deprecated. Compiled packages are cached automatically.
+//
 // The build flags are shared by the build, clean, get, install, list, run,
 // and test commands:
 //
-//	-C dir
-//		Change to dir before running the command.
-//		Any files named on the command line are interpreted after
-//		changing directories.
 //	-a
 //		force rebuilding of packages that are already up-to-date.
 ... (more output is truncated)

What did you expect to see?

No diff when running the git diff command and the extra lines do not need to be modified.

What did you see instead?

Lines not related to the CL are modified.

@empire empire changed the title affected/package: cmd/go: extra lines are modified when generating alldocs.go Feb 8, 2023
@empire empire changed the title cmd/go: extra lines are modified when generating alldocs.go testing:: extra lines are modified when generating alldocs.go Feb 8, 2023
@empire empire changed the title testing:: extra lines are modified when generating alldocs.go testing: extra lines are modified when generating alldocs.go Feb 8, 2023
@bcmills bcmills changed the title testing: extra lines are modified when generating alldocs.go cmd/go/internal/test: stale flagdefs.go not detected by tests Feb 8, 2023
@bcmills bcmills added GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. labels Feb 8, 2023
@bcmills
Copy link
Contributor

bcmills commented Feb 8, 2023

It looks like some changes in the standard library needed to update flagdefs.go but didn't.

We have tests that are supposed to catch that, but for some reason they didn't.

@bcmills bcmills added this to the Go1.21 milestone Feb 8, 2023
@bcmills
Copy link
Contributor

bcmills commented Feb 8, 2023

@gopherbot, please backport to Go 1.20. This masked two missing vet analyzer flags that should be added.

@bcmills bcmills self-assigned this Feb 8, 2023
@gopherbot
Copy link

Change https://go.dev/cl/466635 mentions this issue: cmd/go/internal/test: refresh flagdefs.go and fix test

@gopherbot
Copy link

Backport issue(s) opened: #58421 (for 1.20).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link

Change https://go.dev/cl/466695 mentions this issue: cmd/go: rewrite generate tests using the new maps package

@gopherbot
Copy link

Change https://go.dev/cl/466855 mentions this issue: [release-branch.go1.20] cmd/go/internal/test: refresh flagdefs.go and fix test

gopherbot pushed a commit that referenced this issue Feb 9, 2023
For #58415.

Change-Id: I13c00f28824087e1841a49ec35a3e2a990945137
Reviewed-on: https://go-review.googlesource.com/c/go/+/466695
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Feb 10, 2023
… 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 <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
(cherry picked from commit 910f041)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466855
johanbrandhorst pushed a commit to Pryz/go that referenced this issue Feb 12, 2023
The tests for cmd/go/internal/test were not running at all due to a
missed call to m.Run in TestMain. That masked two missing vet
analyzers ("directive" and "timeformat") and a missed update to the
generator script in CL 355452.

Fixes golang#58415.

Change-Id: I7b0315952967ca07a866cdaa5903478b2873eb7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466635
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
johanbrandhorst pushed a commit to Pryz/go that referenced this issue Feb 12, 2023
For golang#58415.

Change-Id: I13c00f28824087e1841a49ec35a3e2a990945137
Reviewed-on: https://go-review.googlesource.com/c/go/+/466695
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Feb 14, 2023
… 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 golang#58421.
Updates golang#58415.

Change-Id: I7b0315952967ca07a866cdaa5903478b2873eb7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466635
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
(cherry picked from commit 910f041)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466855
@golang golang locked and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants