]> Cypherpunks repositories - gostls13.git/commitdiff
os: don't assume /bin/pwd in test, find it in $PATH
authorRon Minnich <rminnich@gmail.com>
Tue, 29 Aug 2017 16:59:27 +0000 (09:59 -0700)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 29 Aug 2017 20:08:16 +0000 (20:08 +0000)
There are several distros now that no longer have /bin.
Instead of assuming /bin/pwd, we will look for it in $PATH.

Fixes #21684.

Change-Id: I61478326500edeadc3c26803990550dad00c7971
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Reviewed-on: https://go-review.googlesource.com/60010
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/os/os_test.go

index dbe4ff8830e305bca08944b5001b1c4355e1ec6e..c8077863101a730b0f8dbd90195aaeb611bc87dd 100644 (file)
@@ -1014,9 +1014,14 @@ func TestStartProcess(t *testing.T) {
                dir = Getenv("SystemRoot")
                args = []string{"/c", "cd"}
        default:
-               cmd = "/bin/pwd"
+               var err error
+               cmd, err = osexec.LookPath("pwd")
+               if err != nil {
+                       t.Fatalf("Can't find pwd: %v", err)
+               }
                dir = "/"
                args = []string{}
+               t.Logf("Testing with %v", cmd)
        }
        cmddir, cmdbase := filepath.Split(cmd)
        args = append([]string{cmdbase}, args...)