Skip to content

Commit 0245e1d

Browse files
committed
gopls/internal/regtest/codelens: set GOWORK=off for go mod vendor
We might be introducing vendoring for workspace mode. Set GOWORK=off when running go mod vendor in a single module context to make sure it has the right behavior and doesn't return an error. For golang/go#60056 Change-Id: I703d74d579aec6e4dad86ca092e3651e0b2e4eb0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/499977 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Michael Matloob <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 85be888 commit 0245e1d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

gopls/internal/lsp/regtest/wrappers.go

+9
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,15 @@ func (e *Env) RunGoCommandInDir(dir, verb string, args ...string) {
270270
}
271271
}
272272

273+
// RunGoCommandInDirWithEnv is like RunGoCommand, but executes in the given
274+
// relative directory of the sandbox with the given additional environment variables.
275+
func (e *Env) RunGoCommandInDirWithEnv(dir string, env []string, verb string, args ...string) {
276+
e.T.Helper()
277+
if err := e.Sandbox.RunGoCommand(e.Ctx, dir, verb, args, env, true); err != nil {
278+
e.T.Fatal(err)
279+
}
280+
}
281+
273282
// GoVersion checks the version of the go command.
274283
// It returns the X in Go 1.X.
275284
func (e *Env) GoVersion() int {

gopls/internal/regtest/codelens/codelens_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ require golang.org/x/hello v1.2.3
201201
t.Run(fmt.Sprintf("Upgrade individual dependency vendoring=%v", vendoring), func(t *testing.T) {
202202
WithOptions(ProxyFiles(proxyWithLatest)).Run(t, shouldUpdateDep, func(t *testing.T, env *Env) {
203203
if vendoring {
204-
env.RunGoCommandInDir("a", "mod", "vendor")
204+
env.RunGoCommandInDirWithEnv("a", []string{"GOWORK=off"}, "mod", "vendor")
205205
}
206206
env.AfterChange()
207207
env.OpenFile("a/go.mod")

0 commit comments

Comments
 (0)