Fix a lot of noisy logging and test warnings
This commit is contained in:
parent
62b1e1b749
commit
be3f32e962
|
@ -35,15 +35,9 @@ func TestingConfig() *Config {
|
|||
return &Config{
|
||||
ListenAddr: "localhost:0",
|
||||
NoDHT: true,
|
||||
DataDir: func() string {
|
||||
ret, err := ioutil.TempDir(tempDir, "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ret
|
||||
}(),
|
||||
DataDir: tempDir(),
|
||||
DisableTrackers: true,
|
||||
Debug: true,
|
||||
// Debug: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +103,7 @@ func TestTorrentInitialState(t *testing.T) {
|
|||
pieceStateChanges: pubsub.NewPubSub(),
|
||||
}
|
||||
tor.chunkSize = 2
|
||||
tor.storageOpener = storage.NewClient(storage.NewFileWithCompletion("/dev/null", storage.NewMapPieceCompletion()))
|
||||
tor.storageOpener = storage.NewClient(storage.NewFileWithCompletion(tempDir(), storage.NewMapPieceCompletion()))
|
||||
// Needed to lock for asynchronous piece verification.
|
||||
tor.cl = new(Client)
|
||||
tor.cl.mu.Lock()
|
||||
|
|
16
main_test.go
16
main_test.go
|
@ -7,20 +7,30 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
var tempDir string
|
||||
// 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.Llongfile)
|
||||
var err error
|
||||
tempDir, err = ioutil.TempDir("", "torrent.test")
|
||||
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(tempDir)
|
||||
os.RemoveAll(pkgTempDir)
|
||||
// select {}
|
||||
os.Exit(code)
|
||||
}
|
||||
|
|
7
piece.go
7
piece.go
|
@ -2,7 +2,6 @@ package torrent
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/anacrolix/missinggo/bitmap"
|
||||
|
@ -174,13 +173,13 @@ func (p *Piece) VerifyData() {
|
|||
if p.hashing {
|
||||
target++
|
||||
}
|
||||
log.Printf("target: %d", target)
|
||||
// log.Printf("target: %d", target)
|
||||
p.t.queuePieceCheck(p.index)
|
||||
for p.numVerifies < target {
|
||||
log.Printf("got %d verifies", p.numVerifies)
|
||||
// log.Printf("got %d verifies", p.numVerifies)
|
||||
p.t.cl.event.Wait()
|
||||
}
|
||||
log.Print("done")
|
||||
// log.Print("done")
|
||||
}
|
||||
|
||||
func (p *Piece) queuedForHash() bool {
|
||||
|
|
Loading…
Reference in New Issue