diff options
| author | Alex Brainman <alex.brainman@gmail.com> | 2011-03-24 11:20:28 +1100 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2011-03-24 11:20:28 +1100 |
| commit | 913c8d73978795e4f2cdd1f87de3af5239ebdc84 (patch) | |
| tree | 99915ecd3b98adfdaaedff4ac9655892f79db4b5 /src/pkg/exec | |
| parent | eccf31b74492d9735fa981998dc9d86e2ce38c79 (diff) | |
| download | go-913c8d73978795e4f2cdd1f87de3af5239ebdc84.tar.xz | |
syscall: StartProcess fixes for windows
- StartProcess will work with relative (to attr.Dir, not
current directory) executable filenames
- StartProcess will only work if executable filename points
to the real file, it will not search for executable in the
$PATH list and others (see CreateProcess manual for details)
- StartProcess argv strings can contain any characters
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4306041
Diffstat (limited to 'src/pkg/exec')
| -rw-r--r-- | src/pkg/exec/exec_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/pkg/exec/exec_test.go b/src/pkg/exec/exec_test.go index 3a3d3b1a53..5e37b99eec 100644 --- a/src/pkg/exec/exec_test.go +++ b/src/pkg/exec/exec_test.go @@ -118,3 +118,55 @@ func TestAddEnvVar(t *testing.T) { t.Fatal("close:", err) } } + +var tryargs = []string{ + `2`, + `2 `, + "2 \t", + `2" "`, + `2 ab `, + `2 "ab" `, + `2 \ `, + `2 \\ `, + `2 \" `, + `2 \`, + `2\`, + `2"`, + `2\"`, + `2 "`, + `2 \"`, + ``, + `2 ^ `, + `2 \^`, +} + +func TestArgs(t *testing.T) { + for _, a := range tryargs { + argv := []string{ + "awk", + `BEGIN{printf("%s|%s|%s",ARGV[1],ARGV[2],ARGV[3])}`, + "/dev/null", + a, + "EOF", + } + exe, err := LookPath(argv[0]) + if err != nil { + t.Fatal("run:", err) + } + cmd, err := Run(exe, argv, nil, "", DevNull, Pipe, DevNull) + if err != nil { + t.Fatal("run:", err) + } + buf, err := ioutil.ReadAll(cmd.Stdout) + if err != nil { + t.Fatal("read:", err) + } + expect := "/dev/null|" + a + "|EOF" + if string(buf) != expect { + t.Errorf("read: got %q expect %q", buf, expect) + } + if err = cmd.Close(); err != nil { + t.Fatal("close:", err) + } + } +} |
