mirror of
https://github.com/golang/go
synced 2024-11-22 00:34:40 -07:00
exec: enable tests on windows
Fixes #1104. R=golang-dev, mattn, r CC=Joe Poirier, golang-dev https://golang.org/cl/3051041
This commit is contained in:
parent
8f651ff742
commit
a2a4e0c01a
@ -197,7 +197,6 @@ endif
|
|||||||
|
|
||||||
# Disable tests that windows cannot run yet.
|
# Disable tests that windows cannot run yet.
|
||||||
ifeq ($(GOOS),windows)
|
ifeq ($(GOOS),windows)
|
||||||
NOTEST+=exec # no pipe
|
|
||||||
NOTEST+=os/signal # no signals
|
NOTEST+=os/signal # no signals
|
||||||
NOTEST+=path # tree walking does not work
|
NOTEST+=path # tree walking does not work
|
||||||
NOTEST+=syslog # no network
|
NOTEST+=syslog # no network
|
||||||
|
@ -9,15 +9,23 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRunCat(t *testing.T) {
|
func run(argv []string, stdin, stdout, stderr int) (p *Cmd, err os.Error) {
|
||||||
cat, err := LookPath("cat")
|
if runtime.GOOS == "windows" {
|
||||||
if err != nil {
|
argv = append([]string{"cmd", "/c"}, argv...)
|
||||||
t.Fatal("cat: ", err)
|
|
||||||
}
|
}
|
||||||
cmd, err := Run(cat, []string{"cat"}, nil, "",
|
exe, err := LookPath(argv[0])
|
||||||
Pipe, Pipe, DevNull)
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
p, err = Run(exe, argv, nil, "", stdin, stdout, stderr)
|
||||||
|
return p, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRunCat(t *testing.T) {
|
||||||
|
cmd, err := run([]string{"cat"}, Pipe, Pipe, DevNull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("run:", err)
|
t.Fatal("run:", err)
|
||||||
}
|
}
|
||||||
@ -36,11 +44,7 @@ func TestRunCat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRunEcho(t *testing.T) {
|
func TestRunEcho(t *testing.T) {
|
||||||
echo, err := LookPath("echo")
|
cmd, err := run([]string{"sh", "-c", "echo hello world"},
|
||||||
if err != nil {
|
|
||||||
t.Fatal("echo: ", err)
|
|
||||||
}
|
|
||||||
cmd, err := Run(echo, []string{"echo", "hello", "world"}, nil, "",
|
|
||||||
DevNull, Pipe, DevNull)
|
DevNull, Pipe, DevNull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("run:", err)
|
t.Fatal("run:", err)
|
||||||
@ -58,11 +62,7 @@ func TestRunEcho(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStderr(t *testing.T) {
|
func TestStderr(t *testing.T) {
|
||||||
sh, err := LookPath("sh")
|
cmd, err := run([]string{"sh", "-c", "echo hello world 1>&2"},
|
||||||
if err != nil {
|
|
||||||
t.Fatal("sh: ", err)
|
|
||||||
}
|
|
||||||
cmd, err := Run(sh, []string{"sh", "-c", "echo hello world 1>&2"}, nil, "",
|
|
||||||
DevNull, DevNull, Pipe)
|
DevNull, DevNull, Pipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("run:", err)
|
t.Fatal("run:", err)
|
||||||
@ -80,11 +80,7 @@ func TestStderr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMergeWithStdout(t *testing.T) {
|
func TestMergeWithStdout(t *testing.T) {
|
||||||
sh, err := LookPath("sh")
|
cmd, err := run([]string{"sh", "-c", "echo hello world 1>&2"},
|
||||||
if err != nil {
|
|
||||||
t.Fatal("sh: ", err)
|
|
||||||
}
|
|
||||||
cmd, err := Run(sh, []string{"sh", "-c", "echo hello world 1>&2"}, nil, "",
|
|
||||||
DevNull, Pipe, MergeWithStdout)
|
DevNull, Pipe, MergeWithStdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("run:", err)
|
t.Fatal("run:", err)
|
||||||
@ -106,11 +102,7 @@ func TestAddEnvVar(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("setenv:", err)
|
t.Fatal("setenv:", err)
|
||||||
}
|
}
|
||||||
sh, err := LookPath("sh")
|
cmd, err := run([]string{"sh", "-c", "echo $NEWVAR"},
|
||||||
if err != nil {
|
|
||||||
t.Fatal("sh: ", err)
|
|
||||||
}
|
|
||||||
cmd, err := Run(sh, []string{"sh", "-c", "echo $NEWVAR"}, nil, "",
|
|
||||||
DevNull, Pipe, DevNull)
|
DevNull, Pipe, DevNull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("run:", err)
|
t.Fatal("run:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user