Skip to content

Commit

Permalink
gopls/internal/regtest/codelens: set GOWORK=off for go mod vendor
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
matloob committed Jun 13, 2023
1 parent 85be888 commit 0245e1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions gopls/internal/lsp/regtest/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ func (e *Env) RunGoCommandInDir(dir, verb string, args ...string) {
}
}

// RunGoCommandInDirWithEnv is like RunGoCommand, but executes in the given
// relative directory of the sandbox with the given additional environment variables.
func (e *Env) RunGoCommandInDirWithEnv(dir string, env []string, verb string, args ...string) {
e.T.Helper()
if err := e.Sandbox.RunGoCommand(e.Ctx, dir, verb, args, env, true); err != nil {
e.T.Fatal(err)
}
}

// GoVersion checks the version of the go command.
// It returns the X in Go 1.X.
func (e *Env) GoVersion() int {
Expand Down
2 changes: 1 addition & 1 deletion gopls/internal/regtest/codelens/codelens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ require golang.org/x/hello v1.2.3
t.Run(fmt.Sprintf("Upgrade individual dependency vendoring=%v", vendoring), func(t *testing.T) {
WithOptions(ProxyFiles(proxyWithLatest)).Run(t, shouldUpdateDep, func(t *testing.T, env *Env) {
if vendoring {
env.RunGoCommandInDir("a", "mod", "vendor")
env.RunGoCommandInDirWithEnv("a", []string{"GOWORK=off"}, "mod", "vendor")
}
env.AfterChange()
env.OpenFile("a/go.mod")
Expand Down

0 comments on commit 0245e1d

Please sign in to comment.