浏览代码

go.crypto/ssh: skip tests that start ssh-agent.

Also stops leaking /tmp/ directories.

Fixes golang/go#8489.

LGTM=dave, minux
R=dave, minux, agl
CC=golang-codereviews
https://golang.org/cl/124010043
Han-Wen Nienhuys 11 年之前
父节点
当前提交
9e886ee4f2
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      ssh/agent/client_test.go

+ 9 - 0
ssh/agent/client_test.go

@@ -11,13 +11,21 @@ import (
 	"net"
 	"os"
 	"os/exec"
+	"path/filepath"
 	"strconv"
 	"testing"
 
 	"code.google.com/p/go.crypto/ssh"
 )
 
+// startAgent executes ssh-agent, and returns a Agent interface to it.
 func startAgent(t *testing.T) (client Agent, socket string, cleanup func()) {
+	if testing.Short() {
+		// ssh-agent is not always available, and the key
+		// types supported vary by platform.
+		t.Skip("skipping test due to -short")
+	}
+
 	bin, err := exec.LookPath("ssh-agent")
 	if err != nil {
 		t.Skip("could not find ssh-agent")
@@ -66,6 +74,7 @@ func startAgent(t *testing.T) (client Agent, socket string, cleanup func()) {
 			proc.Kill()
 		}
 		conn.Close()
+		os.RemoveAll(filepath.Dir(socket))
 	}
 }