mirror of
https://github.com/golang/go
synced 2024-11-18 15:44:41 -07: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 {
|
||||
pathWithDriver = binDir
|
||||
}
|
||||
coreEnv := exported.Config.Env
|
||||
for _, test := range []struct {
|
||||
desc string
|
||||
path string
|
||||
@ -1979,7 +1978,10 @@ EOF
|
||||
oldPath := os.Getenv(pathKey)
|
||||
os.Setenv(pathKey, test.path)
|
||||
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")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user