github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/util/testutil/ci/ci.go (about) 1 // Package ci implements some helper functions to use during 2 // tests. Many times certain facilities are not available, or tests 3 // must run differently. 4 package ci 5 6 import ( 7 "os" 8 9 jenkins "github.com/ipfs/go-ipfs/util/testutil/ci/jenkins" 10 travis "github.com/ipfs/go-ipfs/util/testutil/ci/travis" 11 ) 12 13 // EnvVar is a type to use travis-only env var names with 14 // the type system. 15 type EnvVar string 16 17 // Environment variables that TravisCI uses. 18 const ( 19 VarCI EnvVar = "CI" 20 VarNoFuse EnvVar = "TEST_NO_FUSE" 21 VarVerbose EnvVar = "TEST_VERBOSE" 22 ) 23 24 // IsRunning attempts to determine whether this process is 25 // running on CI. This is done by checking any of: 26 // 27 // CI=true 28 // travis.IsRunning() 29 // jenkins.IsRunning() 30 // 31 func IsRunning() bool { 32 if os.Getenv(string(VarCI)) == "true" { 33 return true 34 } 35 36 return travis.IsRunning() || jenkins.IsRunning() 37 } 38 39 // Env returns the value of a CI env variable. 40 func Env(v EnvVar) string { 41 return os.Getenv(string(v)) 42 } 43 44 // Returns whether FUSE is explicitly disabled wiht TEST_NO_FUSE. 45 func NoFuse() bool { 46 return os.Getenv(string(VarNoFuse)) == "1" 47 } 48 49 // Returns whether TEST_VERBOSE is enabled. 50 func Verbose() bool { 51 return os.Getenv(string(VarVerbose)) == "1" 52 }