2
0
mirror of synced 2025-02-23 14:18:13 +00:00
torrent/main_test.go
Matt Joiner 6773fa9a7e Fix TestSetMaxEstablishedConn and allow it to be run with -count > 1
Similar changes should occur to other tests exporting StatusWriters.
2018-02-11 15:14:31 +11:00

37 lines
581 B
Go

package torrent
import (
"io/ioutil"
"log"
"os"
"testing"
)
// A top-level temp dir that lasts for the duration of the package tests, and
// is removed at completion.
var pkgTempDir string
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
var err error
pkgTempDir, err = ioutil.TempDir("", "torrent.test")
if err != nil {
panic(err)
}
}
func tempDir() string {
ret, err := ioutil.TempDir(pkgTempDir, "")
if err != nil {
panic(err)
}
return ret
}
func TestMain(m *testing.M) {
code := m.Run()
os.RemoveAll(pkgTempDir)
// select {}
os.Exit(code)
}