1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:38:33 -06:00

go/packages: set GOPACKAGESDRIVER=off for all the tests

Tests that use packagestest.Export already have GOPACKAGESDRIVER=off,
make sure the rest of the tests are setting it off to make sure the
value of GOPACKGESDRIVER doesn't affect tests that are run locally.

Fixes golang/go#33956

Change-Id: If14dce17f413f46a3d36cdf2679e992ec9147a53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192397
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Michael Matloob 2019-08-29 16:07:50 -04:00
parent bce6695301
commit 88604bcfcf

View File

@ -1025,6 +1025,7 @@ const A = 1
`)
config := &packages.Config{
Dir: tmp,
Env: append(os.Environ(), "GOPACKAGESDRIVER=off"),
Mode: packages.LoadAllSyntax,
Overlay: map[string][]byte{
filename: content,
@ -1093,6 +1094,7 @@ go 1.11
// Run packages.Load on mod2, while passing the contents over mod1/main.go in the overlay.
config := &packages.Config{
Dir: mod2,
Env: append(os.Environ(), "GOPACKAGESDRIVER=off"),
Mode: packages.LoadImports,
Overlay: map[string][]byte{
filepath.Join(mod1, "main.go"): []byte(`package main
@ -1757,7 +1759,7 @@ func TestRejectInvalidQueries(t *testing.T) {
queries := []string{"key=", "key=value"}
cfg := &packages.Config{
Mode: packages.LoadImports,
Env: append(os.Environ(), "GO111MODULE=off"),
Env: append(os.Environ(), "GO111MODULE=off", "GOPACKAGESDRIVER=off"),
}
for _, q := range queries {
if _, err := packages.Load(cfg, q); err == nil {
@ -1956,7 +1958,7 @@ func testReturnErrorWhenUsingNonGoFiles(t *testing.T, exporter packagestest.Expo
"b/b.c": `package b`,
}}})
defer exported.Cleanup()
config := packages.Config{}
config := packages.Config{Env: append(os.Environ(), "GOPACKAGESDRIVER=off")}
want := "named files must be .go files"
pkgs, err := packages.Load(&config, "a/a.go", "b/b.c")
if err != nil {