aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-02-28 22:25:06 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2017-02-28 23:05:18 +0000
commite73f4894949c4ced611881329ff8f37805152585 (patch)
treefca8cbcf46e7252c7ba0a3cf2c0960ada04337de /src/os/exec/exec_test.go
parent3c023f75a62f903273c688432f95e77fc945b6fb (diff)
downloadgo-e73f4894949c4ced611881329ff8f37805152585.tar.gz
go-e73f4894949c4ced611881329ff8f37805152585.zip
os/exec: remove duplicate environment variables in Cmd.Start
Nobody intends to have duplicates anyway because it's so undefined and everything handles it so poorly. Removing duplicates automatically simplifies code and makes existing code do what people already expect. Fixes #12868 Change-Id: I95eeba8c59ff94d0f018012a6f4e031aaabfd5d9 Reviewed-on: https://go-review.googlesource.com/37586 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec_test.go')
-rw-r--r--src/os/exec/exec_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
index 13bc39794b..7b69db7c76 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -693,6 +693,11 @@ func TestHelperProcess(*testing.T) {
iargs = append(iargs, s)
}
fmt.Println(iargs...)
+ case "echoenv":
+ for _, s := range args {
+ fmt.Println(os.Getenv(s))
+ }
+ os.Exit(0)
case "cat":
if len(args) == 0 {
io.Copy(os.Stdout, os.Stdin)
@@ -1043,3 +1048,18 @@ func TestContextCancel(t *testing.T) {
t.Logf("exit status: %v", err)
}
}
+
+// test that environment variables are de-duped.
+func TestDedupEnvEcho(t *testing.T) {
+ testenv.MustHaveExec(t)
+
+ cmd := helperCommand(t, "echoenv", "FOO")
+ cmd.Env = append(cmd.Env, "FOO=bad", "FOO=good")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got, want := strings.TrimSpace(string(out)), "good"; got != want {
+ t.Errorf("output = %q; want %q", got, want)
+ }
+}