client_test.go | 15 +++++---------- main_test.go | 14 ++++++++++++++ diff --git a/client_test.go b/client_test.go index 2804d9c8c0ae695d49559a163511b78e29778ffd..7324c49921c6afbd188da9d366e5183141fc7964 100644 --- a/client_test.go +++ b/client_test.go @@ -6,7 +6,6 @@ "errors" "fmt" "io" "io/ioutil" - "log" "math/rand" "net" "os" @@ -32,23 +31,19 @@ "github.com/anacrolix/torrent/metainfo" "github.com/anacrolix/torrent/storage" ) -func init() { - log.SetFlags(log.LstdFlags | log.Llongfile) -} - func TestingConfig() *Config { return &Config{ - ListenAddr: "localhost:0", - NoDHT: true, - DisableTrackers: true, + ListenAddr: "localhost:0", + NoDHT: true, DataDir: func() string { - ret, err := ioutil.TempDir("", "") + ret, err := ioutil.TempDir(tempDir, "") if err != nil { panic(err) } return ret }(), - Debug: true, + DisableTrackers: true, + Debug: true, } } diff --git a/main_test.go b/main_test.go index b6e46230956b125187b093c924a74f2d7983f404..b86d42fc101307b664538d689dab30d6abd9f3ab 100644 --- a/main_test.go +++ b/main_test.go @@ -1,12 +1,26 @@ package torrent import ( + "io/ioutil" + "log" "os" "testing" ) +var tempDir string + +func init() { + log.SetFlags(log.LstdFlags | log.Llongfile) + var err error + tempDir, err = ioutil.TempDir("", "torrent.test") + if err != nil { + panic(err) + } +} + func TestMain(m *testing.M) { code := m.Run() + os.RemoveAll(tempDir) // select {} os.Exit(code) }