gopls/internal/server: print stderr in go mod vendor error message

TestInconsistentVendoring is flaking on Windows with the not-so-helpful
"exit status 1". Include stderr in the error message to help debug.

For golang/go#64229

Change-Id: Iadb946e799e866af683ea9ea7fc039f34b45b1ba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/550375
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Rob Findley 2023-12-15 16:25:14 -05:00 коммит произвёл Gopher Robot
Родитель e601fd80ad
Коммит 3bed1477e2
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -386,12 +386,16 @@ func (c *commandHandler) Vendor(ctx context.Context, args command.URIArg) error
// If golang/go#44119 is resolved, go mod vendor will instead modify
// modules.txt in-place. In that case we could theoretically allow this
// command to run concurrently.
stderr := new(bytes.Buffer)
err := deps.snapshot.RunGoCommandPiped(ctx, cache.Normal|cache.AllowNetwork, &gocommand.Invocation{
Verb: "mod",
Args: []string{"vendor"},
WorkingDir: filepath.Dir(args.URI.Path()),
}, &bytes.Buffer{}, &bytes.Buffer{})
return err
}, &bytes.Buffer{}, stderr)
if err != nil {
return fmt.Errorf("running go mod vendor failed: %v\nstderr:\n%s", err, stderr.String())
}
return nil
})
}