From 88604bcfcf168d1bb75636f2237e59db187e4eb1 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Thu, 29 Aug 2019 16:07:50 -0400 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler --- go/packages/packages_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index 5f42e6a153..0114d01637 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -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 {