diff options
| author | Joe Poirier <jdpoirier@gmail.com> | 2010-09-12 17:38:36 +1000 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2010-09-12 17:38:36 +1000 |
| commit | b155a76a407f8f3f8b48aeeb74d98b25ba27bab4 (patch) | |
| tree | 4abaa41121337a25131111e16fc6372e5398b3fb /src/pkg/exec/exec_test.go | |
| parent | e181bf6e2ffe55014170621b01a09f2d2bbfcf97 (diff) | |
| download | go-b155a76a407f8f3f8b48aeeb74d98b25ba27bab4.tar.xz | |
exec.LookPath() unix/windows separation
R=brainman, rsc, vcc, rsc1
CC=golang-dev
https://golang.org/cl/2068041
Diffstat (limited to 'src/pkg/exec/exec_test.go')
| -rw-r--r-- | src/pkg/exec/exec_test.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/pkg/exec/exec_test.go b/src/pkg/exec/exec_test.go index 898f42582b..04f72cf833 100644 --- a/src/pkg/exec/exec_test.go +++ b/src/pkg/exec/exec_test.go @@ -12,7 +12,11 @@ import ( ) func TestRunCat(t *testing.T) { - cmd, err := Run("/bin/cat", []string{"cat"}, nil, "", + cat, err := LookPath("cat") + if err != nil { + t.Fatal("cat: ", err) + } + cmd, err := Run(cat, []string{"cat"}, nil, "", Pipe, Pipe, DevNull) if err != nil { t.Fatal("run:", err) @@ -32,7 +36,11 @@ func TestRunCat(t *testing.T) { } func TestRunEcho(t *testing.T) { - cmd, err := Run("/bin/echo", []string{"echo", "hello", "world"}, nil, "", + echo, err := LookPath("echo") + if err != nil { + t.Fatal("echo: ", err) + } + cmd, err := Run(echo, []string{"echo", "hello", "world"}, nil, "", DevNull, Pipe, DevNull) if err != nil { t.Fatal("run:", err) @@ -50,7 +58,11 @@ func TestRunEcho(t *testing.T) { } func TestStderr(t *testing.T) { - cmd, err := Run("/bin/sh", []string{"sh", "-c", "echo hello world 1>&2"}, nil, "", + sh, err := LookPath("sh") + if err != nil { + t.Fatal("sh: ", err) + } + cmd, err := Run(sh, []string{"sh", "-c", "echo hello world 1>&2"}, nil, "", DevNull, DevNull, Pipe) if err != nil { t.Fatal("run:", err) @@ -67,9 +79,12 @@ func TestStderr(t *testing.T) { } } - func TestMergeWithStdout(t *testing.T) { - cmd, err := Run("/bin/sh", []string{"sh", "-c", "echo hello world 1>&2"}, nil, "", + sh, err := LookPath("sh") + if err != nil { + t.Fatal("sh: ", err) + } + cmd, err := Run(sh, []string{"sh", "-c", "echo hello world 1>&2"}, nil, "", DevNull, Pipe, MergeWithStdout) if err != nil { t.Fatal("run:", err) @@ -91,7 +106,11 @@ func TestAddEnvVar(t *testing.T) { if err != nil { t.Fatal("setenv:", err) } - cmd, err := Run("/bin/sh", []string{"sh", "-c", "echo $NEWVAR"}, nil, "", + sh, err := LookPath("sh") + if err != nil { + t.Fatal("sh: ", err) + } + cmd, err := Run(sh, []string{"sh", "-c", "echo $NEWVAR"}, nil, "", DevNull, Pipe, DevNull) if err != nil { t.Fatal("run:", err) |
