Skip to content

Commit

Permalink
para: Skip para test when not on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Dec 23, 2020
1 parent f802bb2 commit a9718f4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
6 changes: 6 additions & 0 deletions common/para/para_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"github.com/gohugoio/hugo/htesting"

qt "github.com/frankban/quicktest"
)

Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions htesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package htesting

import (
"math/rand"
"os"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -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") == ""
}
6 changes: 3 additions & 3 deletions hugolib/hugo_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion hugolib/hugo_sites_build_errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)()
}

Expand Down
2 changes: 1 addition & 1 deletion hugolib/hugo_sites_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
}

Expand Down
4 changes: 2 additions & 2 deletions hugolib/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion hugolib/resource_chain_babel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion hugolib/resource_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
4 changes: 0 additions & 4 deletions hugolib/testhelpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9718f4

Please sign in to comment.