commit a9718f44cd6c938448fc697f0ec720ebed7d863a
parent f802bb236a60dcc6c64d53edac634891272e0c07
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Wed, 23 Dec 2020 19:47:20 +0100
para: Skip para test when not on CI
Fixes #6963
Diffstat:
9 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/common/para/para_test.go b/common/para/para_test.go
@@ -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) {
diff --git a/htesting/test_helpers.go b/htesting/test_helpers.go
@@ -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") == ""
+}
diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go
@@ -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")
diff --git a/hugolib/hugo_sites_build_errors_test.go b/hugolib/hugo_sites_build_errors_test.go
@@ -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)()
}
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
@@ -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)()
}
diff --git a/hugolib/js_test.go b/hugolib/js_test.go
@@ -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")
}
diff --git a/hugolib/resource_chain_babel_test.go b/hugolib/resource_chain_babel_test.go
@@ -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")
}
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go
@@ -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")
}
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
@@ -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