зеркало из https://github.com/golang/playground.git
sandbox: pass experiments to vet
Experiments extracted from GOEXPERIMENT were not being passed to vet. Some experiments, such as aliastypeparams, affect vet as well, and so must be set in the vet environment. Change-Id: I7d72c50f5237753b84d26a27fbb09d9bfcf34626 Reviewed-on: https://go-review.googlesource.com/c/playground/+/612456 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com>
This commit is contained in:
Родитель
e948647d23
Коммит
1d4d2693ba
|
@ -503,7 +503,7 @@ func sandboxBuild(ctx context.Context, tmpDir string, in []byte, vet bool) (br *
|
|||
}
|
||||
if vet {
|
||||
// TODO: do this concurrently with the execution to reduce latency.
|
||||
br.vetOut, err = vetCheckInDir(ctx, tmpDir, br.goPath)
|
||||
br.vetOut, err = vetCheckInDir(ctx, tmpDir, br.goPath, exp)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("running vet: %v", err)
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ func sandboxBuild(ctx context.Context, tmpDir string, in []byte, vet bool) (br *
|
|||
}
|
||||
|
||||
// sandboxRun runs a Go binary in a sandbox environment.
|
||||
func sandboxRun(ctx context.Context, exePath string, testParam string) (execRes sandboxtypes.Response, err error) {
|
||||
func sandboxRun(ctx context.Context, exePath, testParam string) (execRes sandboxtypes.Response, err error) {
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
status := "success"
|
||||
|
|
7
vet.go
7
vet.go
|
@ -36,7 +36,7 @@ func vetCheck(ctx context.Context, req *request) (*response, error) {
|
|||
if err := os.WriteFile(in, []byte(req.Body), 0400); err != nil {
|
||||
return nil, fmt.Errorf("error creating temp file %q: %v", in, err)
|
||||
}
|
||||
vetOutput, err := vetCheckInDir(ctx, tmpDir, os.Getenv("GOPATH"))
|
||||
vetOutput, err := vetCheckInDir(ctx, tmpDir, os.Getenv("GOPATH"), nil)
|
||||
if err != nil {
|
||||
// This is about errors running vet, not vet returning output.
|
||||
return nil, err
|
||||
|
@ -49,7 +49,7 @@ func vetCheck(ctx context.Context, req *request) (*response, error) {
|
|||
// go vet was able to run, not whether vet reported problem. The
|
||||
// returned value is ("", nil) if vet successfully found nothing,
|
||||
// and (non-empty, nil) if vet ran and found issues.
|
||||
func vetCheckInDir(ctx context.Context, dir, goPath string) (output string, execErr error) {
|
||||
func vetCheckInDir(ctx context.Context, dir, goPath string, experiments []string) (output string, execErr error) {
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
status := "success"
|
||||
|
@ -72,6 +72,9 @@ func vetCheckInDir(ctx context.Context, dir, goPath string) (output string, exec
|
|||
"GO111MODULE=on",
|
||||
"GOPROXY="+playgroundGoproxy(),
|
||||
)
|
||||
if len(experiments) > 0 {
|
||||
cmd.Env = append(cmd.Env, "GOEXPERIMENT="+strings.Join(experiments, ","))
|
||||
}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
return "", nil
|
||||
|
|
Загрузка…
Ссылка в новой задаче