cmd/gomobile: use exec.LookPath instead of 'which' cmd.
Change-Id: I7fe83d35777b6cb05747c412a69b764994902958 Reviewed-on: https://go-review.googlesource.com/6150 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
f17dcbad8d
commit
cd61880423
|
@ -43,11 +43,11 @@ func TestSignPKCS7(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if exec.Command("which", "openssl").Run() != nil {
|
||||
if openssl, err := exec.LookPath("openssl"); err != nil {
|
||||
t.Log("command openssl not found, skipping")
|
||||
} else {
|
||||
cmd := exec.Command(
|
||||
"openssl", "asn1parse",
|
||||
openssl, "asn1parse",
|
||||
"-inform", "DER",
|
||||
"-i",
|
||||
"-in", sigPath,
|
||||
|
@ -59,10 +59,10 @@ func TestSignPKCS7(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if exec.Command("which", "keytool").Run() != nil {
|
||||
if keytool, err := exec.LookPath("keytool"); err != nil {
|
||||
t.Log("command keytool not found, skipping")
|
||||
} else {
|
||||
cmd := exec.Command("keytool", "-v", "-printcert", "-file", sigPath)
|
||||
cmd := exec.Command(keytool, "-v", "-printcert", "-file", sigPath)
|
||||
out, err := cmd.CombinedOutput()
|
||||
t.Logf("%v:\n%s", cmd.Args, out)
|
||||
if err != nil {
|
||||
|
|
|
@ -313,17 +313,18 @@ func rm(name string) error {
|
|||
}
|
||||
|
||||
func goVersion() ([]byte, error) {
|
||||
if err := exec.Command("which", "go").Run(); err != nil {
|
||||
gobin, err := exec.LookPath("go")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`no Go tool on $PATH`)
|
||||
}
|
||||
buildHelp, err := exec.Command("go", "help", "build").Output()
|
||||
buildHelp, err := exec.Command(gobin, "help", "build").Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bad Go tool: %v", err)
|
||||
}
|
||||
if !bytes.Contains(buildHelp, []byte("-toolexec")) {
|
||||
return nil, fmt.Errorf("installed Go tool does not support -toolexec")
|
||||
}
|
||||
return exec.Command("go", "version").Output()
|
||||
return exec.Command(gobin, "version").Output()
|
||||
}
|
||||
|
||||
func fetchNDK() error {
|
||||
|
|
Loading…
Reference in New Issue