Skip to content

Commit

Permalink
chore(tests) add Short() -> SkipNow() to slowest tests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brian Tiger Chow authored and jbenet committed Nov 15, 2014
1 parent 25b3106 commit ed4a8eb
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 11 deletions.
3 changes: 3 additions & 0 deletions exchange/bitswap/bitswap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions fuse/ipns/ipns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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"
Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand Down Expand Up @@ -198,6 +213,9 @@ func TestAppendFile(t *testing.T) {
}

func TestFastRepublish(t *testing.T) {
if testing.Short() {
t.SkipNow()
}

// make timeout noticeable.
osrt := shortRepublishTimeout
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions importer/chunk/splitting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions importer/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion net/conn/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 6 additions & 2 deletions net/conn/multiconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion net/conn/secure_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions net/mux/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
7 changes: 6 additions & 1 deletion net/swarm/simul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions net/swarm/swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions peer/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
16 changes: 12 additions & 4 deletions routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions routing/dht/ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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{}
Expand Down
3 changes: 3 additions & 0 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed4a8eb

Please sign in to comment.