cmd/go: avoid when go.env contain GOTOOLCHAIN=local test fail

The test fail when $GOROOT/go.env contain GOTOOLCHAIN=local
because GOTOOLCHAIN=local is assumed to be a non-default value.
This CL fixed the test failure
by using go.env from the test as $GOROOT/go.env throughout the test.
Test have also been added to ensure that
when $GOROOT/go.env contain GOTOOLCHAIN=local,
GOTOOLCHAIN=local is not taken as a non-default value.

Fixes #67793

Change-Id: Ibc5057d38d36c6c55726a039de1e7c37d6935b52
GitHub-Last-Rev: 12b62464e6
GitHub-Pull-Request: golang/go#67807
Reviewed-on: https://go-review.googlesource.com/c/go/+/590196
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
qiulaidongfeng 2024-06-06 13:50:29 +00:00 committed by Michael Matloob
parent fbe478521f
commit e709992afd

View file

@ -1,5 +1,6 @@
# Test query for non-defaults in the env
env GOROOT=./a
env GOTOOLCHAIN=local
env GOSUMDB=nodefault
env GOPROXY=nodefault
@ -44,7 +45,6 @@ go env -changed -json GOARCH
[GOARCH:amd64] stdout '"GOARCH": "arm64"'
[!GOARCH:amd64] stdout '"GOARCH": "amd64"'
env GOROOT=./a
env GOPROXY=s
go env -changed GOPROXY
! stdout 'GOPROXY'
@ -52,5 +52,12 @@ env GOPROXY=s2
go env -changed GOPROXY
stdout 'GOPROXY=''?s2''?'
env GOROOT=./b
go env -changed
! stdout 'GOTOOLCHAIN=''?local''?'
-- a/go.env --
GOPROXY=s
-- b/go.env --
GOTOOLCHAIN=local