para: Skip para test when not on CI
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 23 Dec 2020 18:47:20 +0000 (19:47 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 23 Dec 2020 18:47:20 +0000 (19:47 +0100)
Fixes #6963

common/para/para_test.go
htesting/test_helpers.go
hugolib/hugo_modules_test.go
hugolib/hugo_sites_build_errors_test.go
hugolib/hugo_sites_build_test.go
hugolib/js_test.go
hugolib/resource_chain_babel_test.go
hugolib/resource_chain_test.go
hugolib/testhelpers_test.go

index 627528cf9ae200af02e6c1716f8120a7d912e192..646b7b36b77d6e189662cf9d5dba35fca3ac44d5 100644 (file)
@@ -22,6 +22,8 @@ import (
        "testing"
        "time"
 
+       "github.com/gohugoio/hugo/htesting"
+
        qt "github.com/frankban/quicktest"
 )
 
@@ -30,6 +32,10 @@ func TestPara(t *testing.T) {
                t.Skipf("skip para test, CPU count is %d", runtime.NumCPU())
        }
 
+       if !htesting.IsCI() {
+               t.Skip("skip para test when not running on CI")
+       }
+
        c := qt.New(t)
 
        c.Run("Order", func(c *qt.C) {
index 84b36ee27449b37caff4caf6b4d5961691186b33..b584f4ca0b9ac1d04a73167f575fb94de5a1623b 100644 (file)
@@ -15,6 +15,7 @@ package htesting
 
 import (
        "math/rand"
+       "os"
        "runtime"
        "strings"
        "time"
@@ -86,3 +87,7 @@ func DiffStringSlices(slice1 []string, slice2 []string) []string {
 func DiffStrings(s1, s2 string) []string {
        return DiffStringSlices(strings.Fields(s1), strings.Fields(s2))
 }
+
+func IsCI() bool {
+       return (os.Getenv("CI") != "" || os.Getenv("CI_LOCAL") != "") && os.Getenv("CIRCLE_BRANCH") == ""
+}
index 4946d0f5917f5c82118767c606f1c47e850fdac0..fbb232325b22af428dd9ff4edac9583767468738 100644 (file)
@@ -41,7 +41,7 @@ import (
 )
 
 func TestHugoModulesVariants(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
 
@@ -285,12 +285,12 @@ JS imported in module: |
 
 // TODO(bep) this fails when testmodBuilder is also building ...
 func TestHugoModulesMatrix(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
        t.Parallel()
 
-       if !isCI() || hugo.GoMinorVersion() < 12 {
+       if !htesting.IsCI() || hugo.GoMinorVersion() < 12 {
                // https://github.com/golang/go/issues/26794
                // There were some concurrent issues with Go modules in < Go 12.
                t.Skip("skip this on local host and for Go <= 1.11 due to a bug in Go's stdlib")
index 997aae5645e31a39e6432418d436f896b68b043a..efe013c3977c64484d0fc26fdccdec816389983f 100644 (file)
@@ -8,6 +8,7 @@ import (
        "time"
 
        "github.com/fortytw2/leaktest"
+       "github.com/gohugoio/hugo/htesting"
 
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/common/herrors"
@@ -316,7 +317,7 @@ Some content.
 
 // https://github.com/gohugoio/hugo/issues/5375
 func TestSiteBuildTimeout(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                defer leaktest.CheckTimeout(t, 10*time.Second)()
        }
 
index 4d6a8697c4c8065256ffbcca911ed43f829c19ef..fdfc33c5a158db5607b64bc204565ed08cd61e8e 100644 (file)
@@ -414,7 +414,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
 func TestMultiSitesRebuild(t *testing.T) {
        // t.Parallel() not supported, see https://github.com/fortytw2/leaktest/issues/4
        // This leaktest seems to be a little bit shaky on Travis.
-       if !isCI() {
+       if !htesting.IsCI() {
                defer leaktest.CheckTimeout(t, 10*time.Second)()
        }
 
index 8d8e015a6aca14fdcf08ca6c94d1ac10978e61df..a1b74a871a234cb18595655867843c4fae765b85 100644 (file)
@@ -34,7 +34,7 @@ import (
 )
 
 func TestJSBuildWithNPM(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
 
@@ -142,7 +142,7 @@ function greeter(person) {
 }
 
 func TestJSBuild(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
 
index da03c83c78fc22b9f4dcae6936124e8cc648907f..d5e99cd17eb8ec53b54f631c9f644f86b3663eaa 100644 (file)
@@ -36,7 +36,7 @@ import (
 )
 
 func TestResourceChainBabel(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
 
index b5baa4d0bb34364181b7485b6372664aee92ffff..f8b1ccd4d213d30984d6bd7ffb0026c67cf00e0e 100644 (file)
@@ -826,7 +826,7 @@ Hello2: Bonjour
 }
 
 func TestResourceChainPostCSS(t *testing.T) {
-       if !isCI() {
+       if !htesting.IsCI() {
                t.Skip("skip (relative) long running modules test when running locally")
        }
 
index 78d80bebf755fd30af9f181bce9870b0e3487d7d..9e005d767a19e3d395ca65454a2bc3abb22d7652 100644 (file)
@@ -1032,10 +1032,6 @@ func printStringIndexes(s string) {
        }
 }
 
-func isCI() bool {
-       return (os.Getenv("CI") != "" || os.Getenv("CI_LOCAL") != "") && os.Getenv("CIRCLE_BRANCH") == ""
-}
-
 // See https://github.com/golang/go/issues/19280
 // Not in use.
 var parallelEnabled = true