]> Cypherpunks repositories - gostls13.git/commit
cmd/go: derive TestExecutableGOROOT environment from tg.env instead of os.Environ()
authorBryan C. Mills <bcmills@google.com>
Mon, 4 Nov 2019 03:08:35 +0000 (22:08 -0500)
committerBryan C. Mills <bcmills@google.com>
Tue, 5 Nov 2019 16:31:48 +0000 (16:31 +0000)
commit414c1d454e6d388443239209220fe0783d4dac71
tree89b774d7460794f9d0fb3d242899d2acda62d891
parentf0390ffc9d461cb84207b5a94c4b645c87673406
cmd/go: derive TestExecutableGOROOT environment from tg.env instead of os.Environ()

TestExecutableGOROOT, unlike most other tests in go_test.go, was
running subcommands in a process with an environment derived directly
from os.Environ(), rather than using tg.env on its testgoData object.

Since tg.env is what sets GO111MODULE=off for GOPATH-mode tests, that
caused TestExecutableGOROOT to unexpectedly run in module mode instead
of GOPATH mode. If the user's environment included 'GOFLAGS=-mod=mod',
that would cause the test to spuriously fail due to the inability to
download modules to $HOME (which in this test binary is hard-coded to
"/test-go-home-does-not-exist").

Updates #33848

Change-Id: I2f343008dd9e38cd76b9919eafd5a3181d0cbd6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/205064
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/go_test.go
src/cmd/go/testdata/print_goroot.go