]> Cypherpunks repositories - gostls13.git/commitdiff
os: use SameFile in TestStartProcess
authorShenghou Ma <minux.ma@gmail.com>
Thu, 17 Jan 2013 10:48:11 +0000 (18:48 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Thu, 17 Jan 2013 10:48:11 +0000 (18:48 +0800)
Fixes #4650.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/7085048

src/pkg/os/os_test.go

index acce3efe7452a8a1a1f16d44b391ffae6c111951..1268d6b741053b5158e06f9f2bd9c16a93c63586 100644 (file)
@@ -536,8 +536,10 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
        var b bytes.Buffer
        io.Copy(&b, r)
        output := b.String()
-       // Accept /usr prefix because Solaris /bin is symlinked to /usr/bin.
-       if output != expect && output != "/usr"+expect {
+
+       fi1, _ := Stat(strings.TrimSpace(output))
+       fi2, _ := Stat(expect)
+       if !SameFile(fi1, fi2) {
                t.Errorf("exec %q returned %q wanted %q",
                        strings.Join(append([]string{cmd}, args...), " "), output, expect)
        }
@@ -545,15 +547,13 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
 }
 
 func TestStartProcess(t *testing.T) {
-       var dir, cmd, le string
+       var dir, cmd string
        var args []string
        if runtime.GOOS == "windows" {
-               le = "\r\n"
                cmd = Getenv("COMSPEC")
                dir = Getenv("SystemRoot")
                args = []string{"/c", "cd"}
        } else {
-               le = "\n"
                cmd = "/bin/pwd"
                dir = "/"
                args = []string{}
@@ -561,9 +561,9 @@ func TestStartProcess(t *testing.T) {
        cmddir, cmdbase := filepath.Split(cmd)
        args = append([]string{cmdbase}, args...)
        // Test absolute executable path.
-       exec(t, dir, cmd, args, dir+le)
+       exec(t, dir, cmd, args, dir)
        // Test relative executable path.
-       exec(t, cmddir, cmdbase, args, filepath.Clean(cmddir)+le)
+       exec(t, cmddir, cmdbase, args, cmddir)
 }
 
 func checkMode(t *testing.T, path string, mode FileMode) {