para: Skip para test when not on CI

Fixes #6963
This commit is contained in:
Bjørn Erik Pedersen 2020-12-23 19:47:20 +01:00
parent f802bb236a
commit a9718f44cd
No known key found for this signature in database
GPG Key ID: 330E6E2BD4859D8F
9 changed files with 21 additions and 13 deletions

View File

@ -22,6 +22,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/gohugoio/hugo/htesting"
qt "github.com/frankban/quicktest" 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()) 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 := qt.New(t)
c.Run("Order", func(c *qt.C) { c.Run("Order", func(c *qt.C) {

View File

@ -15,6 +15,7 @@ package htesting
import ( import (
"math/rand" "math/rand"
"os"
"runtime" "runtime"
"strings" "strings"
"time" "time"
@ -86,3 +87,7 @@ func DiffStringSlices(slice1 []string, slice2 []string) []string {
func DiffStrings(s1, s2 string) []string { func DiffStrings(s1, s2 string) []string {
return DiffStringSlices(strings.Fields(s1), strings.Fields(s2)) return DiffStringSlices(strings.Fields(s1), strings.Fields(s2))
} }
func IsCI() bool {
return (os.Getenv("CI") != "" || os.Getenv("CI_LOCAL") != "") && os.Getenv("CIRCLE_BRANCH") == ""
}

View File

@ -41,7 +41,7 @@ import (
) )
func TestHugoModulesVariants(t *testing.T) { func TestHugoModulesVariants(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") 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 ... // TODO(bep) this fails when testmodBuilder is also building ...
func TestHugoModulesMatrix(t *testing.T) { func TestHugoModulesMatrix(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") t.Skip("skip (relative) long running modules test when running locally")
} }
t.Parallel() t.Parallel()
if !isCI() || hugo.GoMinorVersion() < 12 { if !htesting.IsCI() || hugo.GoMinorVersion() < 12 {
// https://github.com/golang/go/issues/26794 // https://github.com/golang/go/issues/26794
// There were some concurrent issues with Go modules in < Go 12. // 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") t.Skip("skip this on local host and for Go <= 1.11 due to a bug in Go's stdlib")

View File

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/fortytw2/leaktest" "github.com/fortytw2/leaktest"
"github.com/gohugoio/hugo/htesting"
qt "github.com/frankban/quicktest" qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/common/herrors"
@ -316,7 +317,7 @@ Some content.
// https://github.com/gohugoio/hugo/issues/5375 // https://github.com/gohugoio/hugo/issues/5375
func TestSiteBuildTimeout(t *testing.T) { func TestSiteBuildTimeout(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
defer leaktest.CheckTimeout(t, 10*time.Second)() defer leaktest.CheckTimeout(t, 10*time.Second)()
} }

View File

@ -414,7 +414,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
func TestMultiSitesRebuild(t *testing.T) { func TestMultiSitesRebuild(t *testing.T) {
// t.Parallel() not supported, see https://github.com/fortytw2/leaktest/issues/4 // t.Parallel() not supported, see https://github.com/fortytw2/leaktest/issues/4
// This leaktest seems to be a little bit shaky on Travis. // This leaktest seems to be a little bit shaky on Travis.
if !isCI() { if !htesting.IsCI() {
defer leaktest.CheckTimeout(t, 10*time.Second)() defer leaktest.CheckTimeout(t, 10*time.Second)()
} }

View File

@ -34,7 +34,7 @@ import (
) )
func TestJSBuildWithNPM(t *testing.T) { func TestJSBuildWithNPM(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") t.Skip("skip (relative) long running modules test when running locally")
} }
@ -142,7 +142,7 @@ function greeter(person) {
} }
func TestJSBuild(t *testing.T) { func TestJSBuild(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") t.Skip("skip (relative) long running modules test when running locally")
} }

View File

@ -36,7 +36,7 @@ import (
) )
func TestResourceChainBabel(t *testing.T) { func TestResourceChainBabel(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") t.Skip("skip (relative) long running modules test when running locally")
} }

View File

@ -826,7 +826,7 @@ Hello2: Bonjour
} }
func TestResourceChainPostCSS(t *testing.T) { func TestResourceChainPostCSS(t *testing.T) {
if !isCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running locally") t.Skip("skip (relative) long running modules test when running locally")
} }

View 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 // See https://github.com/golang/go/issues/19280
// Not in use. // Not in use.
var parallelEnabled = true var parallelEnabled = true