]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: make go and moddeps tests insensitive to presence of src/go.work
authorDavid Chase <drchase@google.com>
Wed, 30 Mar 2022 16:01:21 +0000 (12:01 -0400)
committerDavid Chase <drchase@google.com>
Wed, 30 Mar 2022 22:30:03 +0000 (22:30 +0000)
If there is a go.work file in src, "go test cmd/internal/moddeps"
and "go test cmd/go" fail.  Setting GOWORK=off in various command
invocations avoids this problem.

Change-Id: I89fd021ff94998ceda6a3bbc4c3743f08558f98b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396777
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/go/testdata/script/mod_dot.txt
src/cmd/internal/moddeps/moddeps_test.go

index cb60e988b6dfcc671e59c35f31a9f28b08f67ac0..aa24986c72da31d0d48c5db3b364de8b8bab5925 100644 (file)
@@ -1,3 +1,4 @@
+env GOWORK=off
 env GO111MODULE=on
 
 # golang.org/issue/32917 and golang.org/issue/28459: 'go build' and 'go test'
index a63ac71a16a1cbb136e32a6e8f984425e71376a2..053cb8f548cc2fbb9a31c72492085f2eb618d562 100644 (file)
@@ -55,7 +55,7 @@ func TestAllDependencies(t *testing.T) {
                                // dependencies are vendored. If any imported package is missing,
                                // 'go list -deps' will fail when attempting to load it.
                                cmd := exec.Command(goBin, "list", "-mod=vendor", "-deps", "./...")
-                               cmd.Env = append(os.Environ(), "GO111MODULE=on")
+                               cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
                                cmd.Dir = m.Dir
                                cmd.Stderr = new(strings.Builder)
                                _, err := cmd.Output()
@@ -69,7 +69,7 @@ func TestAllDependencies(t *testing.T) {
                        // There is no vendor directory, so the module must have no dependencies.
                        // Check that the list of active modules contains only the main module.
                        cmd := exec.Command(goBin, "list", "-mod=readonly", "-m", "all")
-                       cmd.Env = append(os.Environ(), "GO111MODULE=on")
+                       cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
                        cmd.Dir = m.Dir
                        cmd.Stderr = new(strings.Builder)
                        out, err := cmd.Output()
@@ -197,6 +197,7 @@ func TestAllDependencies(t *testing.T) {
                                        // Add GOROOTcopy/bin and bundleDir to front of PATH.
                                        "PATH="+filepath.Join(gorootCopyDir, "bin")+string(filepath.ListSeparator)+
                                                bundleDir+string(filepath.ListSeparator)+os.Getenv("PATH"),
+                                       "GOWORK=off",
                                ),
                        }
                        goBinCopy := filepath.Join(gorootCopyDir, "bin", "go")
@@ -463,7 +464,7 @@ func findGorootModules(t *testing.T) []gorootModule {
                        // Use 'go list' to describe the module contained in this directory (but
                        // not its dependencies).
                        cmd := exec.Command(goBin, "list", "-json", "-m")
-                       cmd.Env = append(os.Environ(), "GO111MODULE=on")
+                       cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
                        cmd.Dir = dir
                        cmd.Stderr = new(strings.Builder)
                        out, err := cmd.Output()