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: TestScript/env_changed fails when modifying go.env for Go distributions #67793

Closed
dagood opened this issue Jun 3, 2024 · 2 comments
Closed
Assignees
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 release-blocker
Milestone

Comments

@dagood
Copy link
Contributor

dagood commented Jun 3, 2024

Go version

go version devel go1.23-eaa7d9ff86 Mon Jun 3 14:56:37 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/dagood/.cache/go-build'
GOENV='/home/dagood/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/dagood/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dagood/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dagood/git/golang_go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/dagood/git/golang_go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-eaa7d9ff86 Mon Jun 3 14:56:37 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/dagood/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build443899439=/tmp/go-build -gno-record-gcc-switches'

What did you do?

  1. Get latest Go and build it.
  2. Modify go.env to change the last line to GOTOOLCHAIN=local.
  3. Run bin/go test cmd/go -run=Script/^env_changed$

What did you see happen?

vcs-test.golang.org rerouted to http://127.0.0.1:40965
https://vcs-test.golang.org rerouted to https://127.0.0.1:44551
go test proxy running at GOPROXY=http://127.0.0.1:44935/mod
--- FAIL: TestScript (0.02s)
    --- FAIL: TestScript/env_changed (0.01s)
        script_test.go:135: 2024-06-03T17:14:05Z
        script_test.go:137: $WORK=/tmp/cmd-go-test-2664720355/tmpdir3674230406/env_changed1107368237
        script_test.go:159:
            # Test query for non-defaults in the env (0.007s)
            # linux output like GOTOOLCHAIN='local'
            # windows output like GOTOOLCHAIN=local (0.000s)
            > stdout 'GOTOOLCHAIN=''?local''?'
        script_test.go:159: FAIL: testdata/script/env_changed.txt:13: stdout 'GOTOOLCHAIN=''?local''?': no match for `(?m)GOTOOLCHAIN='?local'?` in stdout
FAIL
FAIL    cmd/go  0.054s
FAIL

The test seems to assume that the default go.env is being used, and "changes" the value to GOTOOLCHAIN=local. However, this isn't a change in my case, so the test fails.

https://github.com/golang/go/blob/eaa7d9ff86b35c72cc35bd7c14b349fa414c392f/src/cmd/go/testdata/script/env_changed.txt

What did you expect to see?

https://go.dev/doc/toolchain suggests that it should be possible for repackaged Go toolchains to change this value, so I expected tests to pass.

I'm not quite familiar enough with TestScript to submit a CL off the top of my head that will make the test conditionally skip based on what go.env already contains, but this is the kind of fix I might expect.

It seems like a better fix would be to have the script use GOTOOLCHAIN local if go.env says auto, and use auto if go.env says local, but this might be too complicated.

The workaround for Go repackagers is simple--patch a skip into this test script when there's a go.env modification. IMO this shouldn't be necessary, though.

@dagood dagood changed the title cmd/go: TestScript/env_changed conflicts with modifying go.env for Go distributions cmd/go: TestScript/env_changed fails when modifying go.env for Go distributions Jun 3, 2024
@mknyszek mknyszek added the GoCommand cmd/go label Jun 3, 2024
@mknyszek mknyszek modified the milestones: Backlog, Go1.23 Jun 3, 2024
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 3, 2024
@qiulaidongfeng
Copy link
Member

I will send fix

qiulaidongfeng added a commit to qiulaidongfeng/go that referenced this issue Jun 4, 2024
Fixes golang#67793

Change-Id: Idb079c18c9f4565d95fbf979c73e578872d3732f
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/590196 mentions this issue: cmd/go: avoid when go.env contain GOTOOLCHAIN=local test fail

@joedian joedian added the okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 release-blocker
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants