From ed4a8eb7823be4567a105df37969569595e59fa4 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sat, 15 Nov 2014 00:19:47 -0800 Subject: [PATCH] chore(tests) add Short() -> SkipNow() to slowest tests vanilla: 21.57 real 45.14 user 8.51 sys short: 14.40 real 31.13 user 5.56 sys License: MIT Signed-off-by: Brian Tiger Chow --- exchange/bitswap/bitswap_test.go | 3 +++ fuse/ipns/ipns_test.go | 21 +++++++++++++++++++++ importer/chunk/splitting_test.go | 3 +++ importer/importer_test.go | 12 ++++++++++++ net/conn/conn_test.go | 4 +++- net/conn/multiconn_test.go | 8 ++++++-- net/conn/secure_conn_test.go | 4 +++- net/mux/mux_test.go | 3 +++ net/swarm/simul_test.go | 7 ++++++- net/swarm/swarm_test.go | 3 +++ peer/queue/queue_test.go | 3 +++ routing/dht/dht_test.go | 16 ++++++++++++---- routing/dht/ext_test.go | 8 ++++++-- util/util_test.go | 3 +++ 14 files changed, 87 insertions(+), 11 deletions(-) diff --git a/exchange/bitswap/bitswap_test.go b/exchange/bitswap/bitswap_test.go index 4a01444e5..a851f0f56 100644 --- a/exchange/bitswap/bitswap_test.go +++ b/exchange/bitswap/bitswap_test.go @@ -90,6 +90,9 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) { } func TestSwarm(t *testing.T) { + if testing.Short() { + t.SkipNow() + } net := tn.VirtualNetwork() rs := mock.VirtualRoutingServer() sg := NewSessionGenerator(net, rs) diff --git a/fuse/ipns/ipns_test.go b/fuse/ipns/ipns_test.go index 4f5ba6115..7d8f0e8d1 100644 --- a/fuse/ipns/ipns_test.go +++ b/fuse/ipns/ipns_test.go @@ -83,6 +83,9 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M // Test writing a file and reading it back func TestIpnsBasicIO(t *testing.T) { + if testing.Short() { + t.SkipNow() + } _, mnt := setupIpnsTest(t, nil) defer mnt.Close() @@ -101,6 +104,9 @@ func TestIpnsBasicIO(t *testing.T) { // Test to make sure file changes persist over mounts of ipns func TestFilePersistence(t *testing.T) { + if testing.Short() { + t.SkipNow() + } node, mnt := setupIpnsTest(t, nil) fname := "/local/atestfile" @@ -126,6 +132,9 @@ func TestFilePersistence(t *testing.T) { // Test to make sure the filesystem reports file sizes correctly func TestFileSizeReporting(t *testing.T) { + if testing.Short() { + t.SkipNow() + } _, mnt := setupIpnsTest(t, nil) defer mnt.Close() @@ -144,6 +153,9 @@ func TestFileSizeReporting(t *testing.T) { // Test to make sure you cant create multiple entries with the same name func TestDoubleEntryFailure(t *testing.T) { + if testing.Short() { + t.SkipNow() + } _, mnt := setupIpnsTest(t, nil) defer mnt.Close() @@ -160,6 +172,9 @@ func TestDoubleEntryFailure(t *testing.T) { } func TestAppendFile(t *testing.T) { + if testing.Short() { + t.SkipNow() + } _, mnt := setupIpnsTest(t, nil) defer mnt.Close() @@ -198,6 +213,9 @@ func TestAppendFile(t *testing.T) { } func TestFastRepublish(t *testing.T) { + if testing.Short() { + t.SkipNow() + } // make timeout noticeable. osrt := shortRepublishTimeout @@ -299,6 +317,9 @@ func TestFastRepublish(t *testing.T) { // Test writing a medium sized file one byte at a time func TestMultiWrite(t *testing.T) { + if testing.Short() { + t.SkipNow() + } _, mnt := setupIpnsTest(t, nil) defer mnt.Close() diff --git a/importer/chunk/splitting_test.go b/importer/chunk/splitting_test.go index 0ecb143cb..612da4d09 100644 --- a/importer/chunk/splitting_test.go +++ b/importer/chunk/splitting_test.go @@ -21,6 +21,9 @@ func copyBuf(buf []byte) []byte { } func TestSizeSplitterIsDeterministic(t *testing.T) { + if testing.Short() { + t.SkipNow() + } test := func() { bufR := randBuf(t, 10000000) // crank this up to satisfy yourself. diff --git a/importer/importer_test.go b/importer/importer_test.go index 0b563a19c..e8177aa91 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -19,6 +19,9 @@ import ( // These tests tests a combination of unixfs/io/dagreader and importer/chunk. // Maybe split them up somehow? func TestBuildDag(t *testing.T) { + if testing.Short() { + t.SkipNow() + } td := os.TempDir() fi, err := os.Create(td + "/tmpfi") if err != nil { @@ -40,6 +43,9 @@ func TestBuildDag(t *testing.T) { //Test where calls to read are smaller than the chunk size func TestSizeBasedSplit(t *testing.T) { + if testing.Short() { + t.SkipNow() + } bs := &chunk.SizeSplitter{Size: 512} testFileConsistency(t, bs, 32*512) bs = &chunk.SizeSplitter{Size: 4096} @@ -118,10 +124,16 @@ func arrComp(a, b []byte) error { } func TestMaybeRabinConsistency(t *testing.T) { + if testing.Short() { + t.SkipNow() + } testFileConsistency(t, chunk.NewMaybeRabin(4096), 256*4096) } func TestRabinBlockSize(t *testing.T) { + if testing.Short() { + t.SkipNow() + } buf := new(bytes.Buffer) nbytes := 1024 * 1024 io.CopyN(buf, rand.Reader, int64(nbytes)) diff --git a/net/conn/conn_test.go b/net/conn/conn_test.go index 803b517a7..2852d29f7 100644 --- a/net/conn/conn_test.go +++ b/net/conn/conn_test.go @@ -83,7 +83,9 @@ func TestCancel(t *testing.T) { } func TestCloseLeak(t *testing.T) { - // t.Skip("Skipping in favor of another test") + if testing.Short() { + t.SkipNow() + } if os.Getenv("TRAVIS") == "true" { t.Skip("this doesn't work well on travis") diff --git a/net/conn/multiconn_test.go b/net/conn/multiconn_test.go index aa80cd499..b511d9a3b 100644 --- a/net/conn/multiconn_test.go +++ b/net/conn/multiconn_test.go @@ -156,7 +156,9 @@ func setupMultiConns(t *testing.T, ctx context.Context) (a, b *MultiConn) { } func TestMulticonnSend(t *testing.T) { - // t.Skip("fooo") + if testing.Short() { + t.SkipNow() + } log.Info("TestMulticonnSend") ctx := context.Background() @@ -220,7 +222,9 @@ func TestMulticonnSend(t *testing.T) { } func TestMulticonnSendUnderlying(t *testing.T) { - // t.Skip("fooo") + if testing.Short() { + t.SkipNow() + } log.Info("TestMulticonnSendUnderlying") ctx := context.Background() diff --git a/net/conn/secure_conn_test.go b/net/conn/secure_conn_test.go index f75671480..d345465ac 100644 --- a/net/conn/secure_conn_test.go +++ b/net/conn/secure_conn_test.go @@ -105,7 +105,9 @@ func TestSecureCancel(t *testing.T) { } func TestSecureCloseLeak(t *testing.T) { - // t.Skip("Skipping in favor of another test") + if testing.Short() { + t.SkipNow() + } if os.Getenv("TRAVIS") == "true" { t.Skip("this doesn't work well on travis") } diff --git a/net/mux/mux_test.go b/net/mux/mux_test.go index 7ce096247..d445ff779 100644 --- a/net/mux/mux_test.go +++ b/net/mux/mux_test.go @@ -103,6 +103,9 @@ func TestSimpleMuxer(t *testing.T) { } func TestSimultMuxer(t *testing.T) { + if testing.Short() { + t.SkipNow() + } // run muxer ctx, cancel := context.WithCancel(context.Background()) diff --git a/net/swarm/simul_test.go b/net/swarm/simul_test.go index 253d9784d..114a4dcbf 100644 --- a/net/swarm/simul_test.go +++ b/net/swarm/simul_test.go @@ -11,7 +11,9 @@ import ( ) func TestSimultOpen(t *testing.T) { - // t.Skip("skipping for another test") + if testing.Short() { + t.SkipNow() + } addrs := []string{ "/ip4/127.0.0.1/tcp/1244", @@ -61,6 +63,9 @@ func TestSimultOpenMany(t *testing.T) { } func TestSimultOpenFewStress(t *testing.T) { + if testing.Short() { + t.SkipNow() + } // t.Skip("skipping for another test") num := 10 diff --git a/net/swarm/swarm_test.go b/net/swarm/swarm_test.go index 4dd2a1448..4d9488317 100644 --- a/net/swarm/swarm_test.go +++ b/net/swarm/swarm_test.go @@ -167,6 +167,9 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) { } func TestSwarm(t *testing.T) { + if testing.Short() { + t.SkipNow() + } // t.Skip("skipping for another test") addrs := []string{ diff --git a/peer/queue/queue_test.go b/peer/queue/queue_test.go index efaf2037e..7bc1b42f1 100644 --- a/peer/queue/queue_test.go +++ b/peer/queue/queue_test.go @@ -73,6 +73,9 @@ func newPeerTime(t time.Time) peer.Peer { } func TestSyncQueue(t *testing.T) { + if testing.Short() { + t.SkipNow() + } ctx := context.Background() pq := NewXORDistancePQ(u.Key("11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a31")) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index ffbbef819..133e28b58 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -231,7 +231,9 @@ func TestProvides(t *testing.T) { } func TestProvidesAsync(t *testing.T) { - // t.Skip("skipping test to debug another") + if testing.Short() { + t.SkipNow() + } ctx := context.Background() u.Debug = false @@ -295,7 +297,9 @@ func TestProvidesAsync(t *testing.T) { } func TestLayeredGet(t *testing.T) { - // t.Skip("skipping test to debug another") + if testing.Short() { + t.SkipNow() + } ctx := context.Background() u.Debug = false @@ -347,7 +351,9 @@ func TestLayeredGet(t *testing.T) { } func TestFindPeer(t *testing.T) { - // t.Skip("skipping test to debug another") + if testing.Short() { + t.SkipNow() + } ctx := context.Background() u.Debug = false @@ -391,7 +397,9 @@ func TestFindPeer(t *testing.T) { } func TestConnectCollision(t *testing.T) { - // t.Skip("skipping test to debug another") + if testing.Short() { + t.SkipNow() + } runTimes := 10 diff --git a/routing/dht/ext_test.go b/routing/dht/ext_test.go index 1dabb5b64..6be939bed 100644 --- a/routing/dht/ext_test.go +++ b/routing/dht/ext_test.go @@ -115,7 +115,9 @@ func (f *fauxNet) GetBandwidthTotals() (uint64, uint64) { func (f *fauxNet) Close() error { return nil } func TestGetFailures(t *testing.T) { - // t.Skip("skipping test because it makes a lot of output") + if testing.Short() { + t.SkipNow() + } ctx := context.Background() fn := &fauxNet{} @@ -211,7 +213,9 @@ func _randPeer() peer.Peer { } func TestNotFound(t *testing.T) { - // t.Skip("skipping test because it makes a lot of output") + if testing.Short() { + t.SkipNow() + } ctx := context.Background() fn := &fauxNet{} diff --git a/util/util_test.go b/util/util_test.go index 08f3f120a..afd34b10e 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -29,6 +29,9 @@ func TestKey(t *testing.T) { } func TestByteChanReader(t *testing.T) { + if testing.Short() { + t.SkipNow() + } var data bytes.Buffer var data2 bytes.Buffer