@cryptotaxi247 / kubo / commits / ed4a8eb78

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 <brian@perfmode.com>

Brian Tiger Chow committed Nov 15, 2014 at 00:19 UTC ed4a8eb7823be4567a105df37969569595e59fa4
14 files changed +87 -11
exchange/bitswap/bitswap_test.go
+3
@@ -90,6 +90,9 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
90 }
91
92 func TestSwarm(t *testing.T) {
93 + if testing.Short() {
94 + t.SkipNow()
95 + }
96 net := tn.VirtualNetwork()
97 rs := mock.VirtualRoutingServer()
98 sg := NewSessionGenerator(net, rs)
fuse/ipns/ipns_test.go
+21
@@ -83,6 +83,9 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M
83
84 // Test writing a file and reading it back
85 func TestIpnsBasicIO(t *testing.T) {
86 + if testing.Short() {
87 + t.SkipNow()
88 + }
89 _, mnt := setupIpnsTest(t, nil)
90 defer mnt.Close()
91
@@ -101,6 +104,9 @@ func TestIpnsBasicIO(t *testing.T) {
104
105 // Test to make sure file changes persist over mounts of ipns
106 func TestFilePersistence(t *testing.T) {
107 + if testing.Short() {
108 + t.SkipNow()
109 + }
110 node, mnt := setupIpnsTest(t, nil)
111
112 fname := "/local/atestfile"
@@ -126,6 +132,9 @@ func TestFilePersistence(t *testing.T) {
132
133 // Test to make sure the filesystem reports file sizes correctly
134 func TestFileSizeReporting(t *testing.T) {
135 + if testing.Short() {
136 + t.SkipNow()
137 + }
138 _, mnt := setupIpnsTest(t, nil)
139 defer mnt.Close()
140
@@ -144,6 +153,9 @@ func TestFileSizeReporting(t *testing.T) {
153
154 // Test to make sure you cant create multiple entries with the same name
155 func TestDoubleEntryFailure(t *testing.T) {
156 + if testing.Short() {
157 + t.SkipNow()
158 + }
159 _, mnt := setupIpnsTest(t, nil)
160 defer mnt.Close()
161
@@ -160,6 +172,9 @@ func TestDoubleEntryFailure(t *testing.T) {
172 }
173
174 func TestAppendFile(t *testing.T) {
175 + if testing.Short() {
176 + t.SkipNow()
177 + }
178 _, mnt := setupIpnsTest(t, nil)
179 defer mnt.Close()
180
@@ -198,6 +213,9 @@ func TestAppendFile(t *testing.T) {
213 }
214
215 func TestFastRepublish(t *testing.T) {
216 + if testing.Short() {
217 + t.SkipNow()
218 + }
219
220 // make timeout noticeable.
221 osrt := shortRepublishTimeout
@@ -299,6 +317,9 @@ func TestFastRepublish(t *testing.T) {
317
318 // Test writing a medium sized file one byte at a time
319 func TestMultiWrite(t *testing.T) {
320 + if testing.Short() {
321 + t.SkipNow()
322 + }
323
324 _, mnt := setupIpnsTest(t, nil)
325 defer mnt.Close()
importer/chunk/splitting_test.go
+3
@@ -21,6 +21,9 @@ func copyBuf(buf []byte) []byte {
21 }
22
23 func TestSizeSplitterIsDeterministic(t *testing.T) {
24 + if testing.Short() {
25 + t.SkipNow()
26 + }
27
28 test := func() {
29 bufR := randBuf(t, 10000000) // crank this up to satisfy yourself.
importer/importer_test.go
+12
@@ -19,6 +19,9 @@ import (
19 // These tests tests a combination of unixfs/io/dagreader and importer/chunk.
20 // Maybe split them up somehow?
21 func TestBuildDag(t *testing.T) {
22 + if testing.Short() {
23 + t.SkipNow()
24 + }
25 td := os.TempDir()
26 fi, err := os.Create(td + "/tmpfi")
27 if err != nil {
@@ -40,6 +43,9 @@ func TestBuildDag(t *testing.T) {
43
44 //Test where calls to read are smaller than the chunk size
45 func TestSizeBasedSplit(t *testing.T) {
46 + if testing.Short() {
47 + t.SkipNow()
48 + }
49 bs := &chunk.SizeSplitter{Size: 512}
50 testFileConsistency(t, bs, 32*512)
51 bs = &chunk.SizeSplitter{Size: 4096}
@@ -118,10 +124,16 @@ func arrComp(a, b []byte) error {
124 }
125
126 func TestMaybeRabinConsistency(t *testing.T) {
127 + if testing.Short() {
128 + t.SkipNow()
129 + }
130 testFileConsistency(t, chunk.NewMaybeRabin(4096), 256*4096)
131 }
132
133 func TestRabinBlockSize(t *testing.T) {
134 + if testing.Short() {
135 + t.SkipNow()
136 + }
137 buf := new(bytes.Buffer)
138 nbytes := 1024 * 1024
139 io.CopyN(buf, rand.Reader, int64(nbytes))
net/conn/conn_test.go
+3 -1
@@ -83,7 +83,9 @@ func TestCancel(t *testing.T) {
83 }
84
85 func TestCloseLeak(t *testing.T) {
86 - // t.Skip("Skipping in favor of another test")
86 + if testing.Short() {
87 + t.SkipNow()
88 + }
89
90 if os.Getenv("TRAVIS") == "true" {
91 t.Skip("this doesn't work well on travis")
net/conn/multiconn_test.go
+6 -2
@@ -156,7 +156,9 @@ func setupMultiConns(t *testing.T, ctx context.Context) (a, b *MultiConn) {
156 }
157
158 func TestMulticonnSend(t *testing.T) {
159 - // t.Skip("fooo")
159 + if testing.Short() {
160 + t.SkipNow()
161 + }
162
163 log.Info("TestMulticonnSend")
164 ctx := context.Background()
@@ -220,7 +222,9 @@ func TestMulticonnSend(t *testing.T) {
222 }
223
224 func TestMulticonnSendUnderlying(t *testing.T) {
223 - // t.Skip("fooo")
225 + if testing.Short() {
226 + t.SkipNow()
227 + }
228
229 log.Info("TestMulticonnSendUnderlying")
230 ctx := context.Background()
net/conn/secure_conn_test.go
+3 -1
@@ -105,7 +105,9 @@ func TestSecureCancel(t *testing.T) {
105 }
106
107 func TestSecureCloseLeak(t *testing.T) {
108 - // t.Skip("Skipping in favor of another test")
108 + if testing.Short() {
109 + t.SkipNow()
110 + }
111 if os.Getenv("TRAVIS") == "true" {
112 t.Skip("this doesn't work well on travis")
113 }
net/mux/mux_test.go
+3
@@ -103,6 +103,9 @@ func TestSimpleMuxer(t *testing.T) {
103 }
104
105 func TestSimultMuxer(t *testing.T) {
106 + if testing.Short() {
107 + t.SkipNow()
108 + }
109 // run muxer
110 ctx, cancel := context.WithCancel(context.Background())
111
net/swarm/simul_test.go
+6 -1
@@ -11,7 +11,9 @@ import (
11 )
12
13 func TestSimultOpen(t *testing.T) {
14 - // t.Skip("skipping for another test")
14 + if testing.Short() {
15 + t.SkipNow()
16 + }
17
18 addrs := []string{
19 "/ip4/127.0.0.1/tcp/1244",
@@ -61,6 +63,9 @@ func TestSimultOpenMany(t *testing.T) {
63 }
64
65 func TestSimultOpenFewStress(t *testing.T) {
66 + if testing.Short() {
67 + t.SkipNow()
68 + }
69 // t.Skip("skipping for another test")
70
71 num := 10
net/swarm/swarm_test.go
+3
@@ -167,6 +167,9 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
167 }
168
169 func TestSwarm(t *testing.T) {
170 + if testing.Short() {
171 + t.SkipNow()
172 + }
173 // t.Skip("skipping for another test")
174
175 addrs := []string{
peer/queue/queue_test.go
+3
@@ -73,6 +73,9 @@ func newPeerTime(t time.Time) peer.Peer {
73 }
74
75 func TestSyncQueue(t *testing.T) {
76 + if testing.Short() {
77 + t.SkipNow()
78 + }
79 ctx := context.Background()
80
81 pq := NewXORDistancePQ(u.Key("11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a31"))
routing/dht/dht_test.go
+12 -4
@@ -231,7 +231,9 @@ func TestProvides(t *testing.T) {
231 }
232
233 func TestProvidesAsync(t *testing.T) {
234 - // t.Skip("skipping test to debug another")
234 + if testing.Short() {
235 + t.SkipNow()
236 + }
237
238 ctx := context.Background()
239 u.Debug = false
@@ -295,7 +297,9 @@ func TestProvidesAsync(t *testing.T) {
297 }
298
299 func TestLayeredGet(t *testing.T) {
298 - // t.Skip("skipping test to debug another")
300 + if testing.Short() {
301 + t.SkipNow()
302 + }
303
304 ctx := context.Background()
305 u.Debug = false
@@ -347,7 +351,9 @@ func TestLayeredGet(t *testing.T) {
351 }
352
353 func TestFindPeer(t *testing.T) {
350 - // t.Skip("skipping test to debug another")
354 + if testing.Short() {
355 + t.SkipNow()
356 + }
357
358 ctx := context.Background()
359 u.Debug = false
@@ -391,7 +397,9 @@ func TestFindPeer(t *testing.T) {
397 }
398
399 func TestConnectCollision(t *testing.T) {
394 - // t.Skip("skipping test to debug another")
400 + if testing.Short() {
401 + t.SkipNow()
402 + }
403
404 runTimes := 10
405
routing/dht/ext_test.go
+6 -2
@@ -115,7 +115,9 @@ func (f *fauxNet) GetBandwidthTotals() (uint64, uint64) {
115 func (f *fauxNet) Close() error { return nil }
116
117 func TestGetFailures(t *testing.T) {
118 - // t.Skip("skipping test because it makes a lot of output")
118 + if testing.Short() {
119 + t.SkipNow()
120 + }
121
122 ctx := context.Background()
123 fn := &fauxNet{}
@@ -211,7 +213,9 @@ func _randPeer() peer.Peer {
213 }
214
215 func TestNotFound(t *testing.T) {
214 - // t.Skip("skipping test because it makes a lot of output")
216 + if testing.Short() {
217 + t.SkipNow()
218 + }
219
220 ctx := context.Background()
221 fn := &fauxNet{}
util/util_test.go
+3
@@ -29,6 +29,9 @@ func TestKey(t *testing.T) {
29 }
30
31 func TestByteChanReader(t *testing.T) {
32 + if testing.Short() {
33 + t.SkipNow()
34 + }
35
36 var data bytes.Buffer
37 var data2 bytes.Buffer