From ee07305c2a15b20d15702a7c8ba42fafcbc69a6f Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Tue, 17 Jun 2014 16:59:05 +1000 Subject: [PATCH] go.tools/dashboard/builder: skip "path" environment variable on windows "PATH" and "path" are one and the same environment variable on windows. We set PATH variable, while "path" is set to its original value. Windows might use either for the sub-process. LGTM=adg R=golang-codereviews, adg CC=golang-codereviews https://golang.org/cl/109980043 --- dashboard/builder/env.go | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/dashboard/builder/env.go b/dashboard/builder/env.go index 9a27aeaa..759051f2 100644 --- a/dashboard/builder/env.go +++ b/dashboard/builder/env.go @@ -16,25 +16,6 @@ import ( "code.google.com/p/go.tools/go/vcs" ) -// These variables are copied from the gobuilder's environment -// to the envv of its subprocesses. -var extraEnv = []string{ - "GOARM", - "GO386", - "CGO_ENABLED", - - // For Unix derivatives. - "CC", - "PATH", - "TMPDIR", - "USER", - - // For Plan 9. - "objtype", - "cputype", - "path", -} - // builderEnv represents the environment that a Builder will run tests in. type builderEnv interface { // setup sets up the builder environment and returns the directory to run the buildCmd in. @@ -71,7 +52,7 @@ func (b *Builder) envv() []string { } } - for _, k := range extraEnv { + for _, k := range extraEnv() { if s, ok := getenvOk(k); ok { e = append(e, k+"="+s) } @@ -92,7 +73,7 @@ func (b *Builder) envvWindows() []string { } } - for _, name := range extraEnv { + for _, name := range extraEnv() { if s, ok := getenvOk(name); ok { start[name] = s } @@ -276,3 +257,21 @@ func getenvOk(k string) (v string, ok bool) { } return "", false } + +// extraEnv returns environment variables that need to be copied from +// the gobuilder's environment to the envv of its subprocesses. +func extraEnv() []string { + extra := []string{ + "GOARM", + "GO386", + "CGO_ENABLED", + "CC", + "PATH", + "TMPDIR", + "USER", + } + if runtime.GOOS == "plan9" { + extra = append(extra, "objtype", "cputype", "path") + } + return extra +}