mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
go/packages: make a copy of the config.Env slice in the test.
Before this change, we were "saving" config.Env and then appending to it to create a new slice, like so: savedEnv := config.Env ... // for each test case config.Env = append(savedEnv, additionalValue) but we're modifying savedEnv during each env. Even though it might work, it's not doing what we expect. Clean this up. Change-Id: Idcf8199d836241df2b934308863512c566c0c485 Reviewed-on: https://go-review.googlesource.com/c/tools/+/200769 Run-TryBot: Michael Matloob <matloob@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
7667e13ae9
commit
4c025a95b2
@ -1951,7 +1951,6 @@ EOF
|
|||||||
} else {
|
} else {
|
||||||
pathWithDriver = binDir
|
pathWithDriver = binDir
|
||||||
}
|
}
|
||||||
coreEnv := exported.Config.Env
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
desc string
|
desc string
|
||||||
path string
|
path string
|
||||||
@ -1979,7 +1978,10 @@ EOF
|
|||||||
oldPath := os.Getenv(pathKey)
|
oldPath := os.Getenv(pathKey)
|
||||||
os.Setenv(pathKey, test.path)
|
os.Setenv(pathKey, test.path)
|
||||||
defer os.Setenv(pathKey, oldPath)
|
defer os.Setenv(pathKey, oldPath)
|
||||||
exported.Config.Env = append(coreEnv, "GOPACKAGESDRIVER="+test.driver)
|
// Clone exported.Config
|
||||||
|
config := exported.Config
|
||||||
|
config.Env = append([]string{}, exported.Config.Env...)
|
||||||
|
config.Env = append(config.Env, "GOPACKAGESDRIVER="+test.driver)
|
||||||
pkgs, err := packages.Load(exported.Config, "golist")
|
pkgs, err := packages.Load(exported.Config, "golist")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user