@cryptotaxi247 / kubo / commits / 0311c0518

testing/ci: all env var checks now use new pkgs

Good thing, i checked one wrong, too!

Juan Batiz-Benet committed Jan 14, 2015 at 15:43 UTC 0311c0518da08c90645dbeebb77e4cbc4950968d
6 files changed +23 -23
fuse/ipns/ipns_test.go
+5 -9
@@ -5,24 +5,20 @@ import (
5 "crypto/rand"
6 "io/ioutil"
7 "os"
8 - "strings"
8 "testing"
9 "time"
10
11 fstest "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs/fstestutil"
12 +
13 core "github.com/jbenet/go-ipfs/core"
14 u "github.com/jbenet/go-ipfs/util"
15 + ci "github.com/jbenet/go-ipfs/util/testutil/ci"
16 )
17
17 -func maybeSkipFuseTests(t *testing.T) bool {
18 - v := "TEST_NO_FUSE"
19 - n := strings.ToLower(os.Getenv(v))
20 - skip := n != "" && n != "false" && n != "f"
21 -
22 - if skip {
23 - t.Skipf("Skipping FUSE tests (%s=%s)", v, n)
18 +func maybeSkipFuseTests(t *testing.T) {
19 + if ci.NoFuse() {
20 + t.Skip("Skipping FUSE tests")
21 }
25 - return skip
22 }
23
24 func randBytes(size int) []byte {
p2p/net/conn/conn_test.go
+3 -2
@@ -3,13 +3,14 @@ package conn
3 import (
4 "bytes"
5 "fmt"
6 - "os"
6 "runtime"
7 "sync"
8 "testing"
9 "time"
10
11 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
12 +
13 + travis "github.com/jbenet/go-ipfs/util/testutil/ci/travis"
14 )
15
16 func testOneSendRecv(t *testing.T, c1, c2 Conn) {
@@ -62,7 +63,7 @@ func TestCloseLeak(t *testing.T) {
63 t.SkipNow()
64 }
65
65 - if os.Getenv("TRAVIS") == "true" {
66 + if travis.IsRunning() {
67 t.Skip("this doesn't work well on travis")
68 }
69
p2p/net/conn/secure_conn_test.go
+2 -2
@@ -2,13 +2,13 @@ package conn
2
3 import (
4 "bytes"
5 - "os"
5 "runtime"
6 "sync"
7 "testing"
8 "time"
9
10 ic "github.com/jbenet/go-ipfs/p2p/crypto"
11 + travis "github.com/jbenet/go-ipfs/util/testutil/ci/travis"
12
13 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
14 )
@@ -131,7 +131,7 @@ func TestSecureCloseLeak(t *testing.T) {
131 if testing.Short() {
132 t.SkipNow()
133 }
134 - if os.Getenv("TRAVIS") == "true" {
134 + if travis.IsRunning() {
135 t.Skip("this doesn't work well on travis")
136 }
137
p2p/net/swarm/dial_test.go
+7 -5
@@ -2,14 +2,16 @@ package swarm
2
3 import (
4 "net"
5 - "os"
5 "sync"
6 "testing"
7 "time"
8
9 addrutil "github.com/jbenet/go-ipfs/p2p/net/swarm/addr"
10 peer "github.com/jbenet/go-ipfs/p2p/peer"
11 +
12 testutil "github.com/jbenet/go-ipfs/util/testutil"
13 + jenkins "github.com/jbenet/go-ipfs/util/testutil/ci/jenkins"
14 + travis "github.com/jbenet/go-ipfs/util/testutil/ci/travis"
15
16 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
17 ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
@@ -114,7 +116,7 @@ func TestDialWait(t *testing.T) {
116 defer s1.Close()
117
118 s1.dialT = time.Millisecond * 300 // lower timeout for tests.
117 - if os.Getenv("TRAVIS") == "true" {
119 + if travis.IsRunning() {
120 s1.dialT = time.Second
121 }
122
@@ -148,8 +150,8 @@ func TestDialWait(t *testing.T) {
150
151 func TestDialBackoff(t *testing.T) {
152 // t.Skip("skipping for another test")
151 - if os.Getenv("TRAVIS") == "true" {
152 - t.Skip("travis will never have fun with this test")
153 + if travis.IsRunning() || jenkins.IsRunning() {
154 + t.Skip("travis and jenkins will never have fun with this test")
155 }
156
157 t.Parallel()
@@ -375,7 +377,7 @@ func TestDialBackoffClears(t *testing.T) {
377 defer s2.Close()
378 s1.dialT = time.Millisecond * 300 // lower timeout for tests.
379 s2.dialT = time.Millisecond * 300 // lower timeout for tests.
378 - if os.Getenv("TRAVIS") == "true" {
380 + if travis.IsRunning() {
381 s1.dialT = time.Second
382 s2.dialT = time.Second
383 }
util/ctx/fracctx_test.go
+4 -3
@@ -1,16 +1,17 @@
1 package ctxutil
2
3 import (
4 - "os"
4 "testing"
5 "time"
6
7 + travis "github.com/jbenet/go-ipfs/util/testutil/ci/travis"
8 +
9 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
10 )
11
12 // this test is on the context tool itself, not our stuff. it's for sanity on ours.
13 func TestDeadline(t *testing.T) {
13 - if os.Getenv("TRAVIS") == "true" {
14 + if travis.IsRunning() {
15 t.Skip("timeouts don't work reliably on travis")
16 }
17
@@ -42,7 +43,7 @@ func TestDeadlineFractionForever(t *testing.T) {
43 }
44
45 func TestDeadlineFractionHalf(t *testing.T) {
45 - if os.Getenv("TRAVIS") == "true" {
46 + if travis.IsRunning() {
47 t.Skip("timeouts don't work reliably on travis")
48 }
49
util/testutil/ci/ci.go
+2 -2
@@ -42,11 +42,11 @@ func Env(v EnvVar) string {
42 }
43
44 // Returns whether FUSE is explicitly disabled wiht TEST_NO_FUSE.
45 -func NoFuse(v EnvVar) bool {
45 +func NoFuse() bool {
46 return os.Getenv(string(VarNoFuse)) == "1"
47 }
48
49 // Returns whether TEST_VERBOSE is enabled.
50 -func Verbose(v EnvVar) bool {
50 +func Verbose() bool {
51 return os.Getenv(string(VarVerbose)) == "1"
52 }