testing: Skip some slow tests when not running in CI

Fixes #14438
This commit is contained in:
Bjørn Erik Pedersen
2026-01-27 10:20:39 +01:00
parent b3ea2a5fab
commit 5f5b2f378f
14 changed files with 54 additions and 3 deletions
+3
View File
@@ -18,6 +18,8 @@ import (
"fmt"
"io"
"strings"
"github.com/gohugoio/hugo/htesting"
"sync"
"testing"
"time"
@@ -160,6 +162,7 @@ dir = ":cacheDir/c"
}
func TestFileCacheConcurrent(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
t.Parallel()
c := qt.New(t)
+8
View File
@@ -105,6 +105,14 @@ func DiffStrings(s1, s2 string) []string {
return DiffStringSlices(strings.Fields(s1), strings.Fields(s2))
}
// SkipSlowTestUnlessCI skips the test unless we're running in a CI server.
// Note that you can set CI_LOCAL=1 to run slow tests locally in a CI-like setup.
func SkipSlowTestUnlessCI(t testing.TB) {
if !IsCI() {
t.Skip("skipping slow test in CI")
}
}
// IsCI reports whether we're running in a CI server.
func IsCI() bool {
return (os.Getenv("CI") != "" || os.Getenv("CI_LOCAL") != "") && os.Getenv("CIRCLE_BRANCH") == ""
+2
View File
@@ -21,6 +21,7 @@ import (
"github.com/bep/logg"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/config/allconfig"
@@ -711,6 +712,7 @@ themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
// Issue #11089
func TestHugoConfigSliceOverrides(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
t.Parallel()
filesTemplate := `
+2 -2
View File
@@ -562,7 +562,7 @@ func TestSiteBuildTimeout(t *testing.T) {
var filesBuilder strings.Builder
filesBuilder.WriteString(`
-- hugo.toml --
timeout = 5
timeout = '100ms'
-- layouts/single.html --
{{ .WordCount }}
-- layouts/_shortcodes/c.html --
@@ -571,7 +571,7 @@ timeout = 5
{{ end }}
`)
for i := 1; i < 100; i++ {
for i := range 20 {
filesBuilder.WriteString(fmt.Sprintf(`
-- content/page%d.md --
---
+14 -1
View File
@@ -571,6 +571,7 @@ date: 2012-01-12
func TestPageSummary(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
checkPageTitle(t, p, "SimpleWithoutSummaryDelimiter")
@@ -586,6 +587,7 @@ func TestPageSummary(t *testing.T) {
}
func TestPageWithDelimiter(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
t.Parallel()
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
@@ -600,6 +602,7 @@ func TestPageWithDelimiter(t *testing.T) {
func TestPageWithSummaryParameter(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
checkPageTitle(t, p, "SimpleWithSummaryParameter")
@@ -617,6 +620,9 @@ func TestPageWithSummaryParameter(t *testing.T) {
// Issue #3854
// Also see https://github.com/gohugoio/hugo/issues/3977
func TestPageWithDateFields(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
c := qt.New(t)
pageWithDate := `---
title: P%d
@@ -633,7 +639,6 @@ Simple Page With Some Date`
return fmt.Sprintf(pageWithDate, weight, weight, field)
}
t.Parallel()
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
c.Assert(len(pages) > 0, qt.Equals, true)
for _, p := range pages {
@@ -698,6 +703,7 @@ baseURL = "http://example.com/"
}
func TestPageWithMoreTag(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
t.Parallel()
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
@@ -797,6 +803,7 @@ Content: {{ .Content }}|
// #2973
func TestSummaryWithHTMLTagsOnNextLine(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
c := qt.New(t)
p := pages[0]
@@ -875,6 +882,7 @@ home = ["HTML", "JSON"]
// Issue 8919
func TestContentProviderWithCustomOutputFormat(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
files := `
-- hugo.toml --
@@ -1150,6 +1158,7 @@ date = ["` + dateHandler + `", "date"]
func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
if p.WordCount(context.Background()) != 8 {
@@ -1162,6 +1171,7 @@ func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage(t *testing.T) {
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
settings := map[string]any{"hasCJKLanguage": true}
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
@@ -1175,6 +1185,7 @@ func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
settings := map[string]any{"hasCJKLanguage": true}
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
@@ -1189,6 +1200,7 @@ func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
settings := map[string]any{
"hasCJKLanguage": true,
}
@@ -1205,6 +1217,7 @@ func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
func TestWordCount(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
if p.WordCount(context.Background()) != 483 {
@@ -24,6 +24,7 @@ import (
"github.com/bep/logg"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/internal/js/esbuild"
)
@@ -428,6 +429,7 @@ func TestBatchErrorScriptResourceInBundleSyntaxError(t *testing.T) {
}
func TestBatch(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
files := `
-- hugo.toml --
disableKinds = ["taxonomy", "term"]
+1
View File
@@ -34,6 +34,7 @@ import (
)
func TestClient(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
modName := "hugo-modules-basic-test"
modPath := "github.com/gohugoio/tests/" + modName
defaultImport := "modh2_2"
@@ -18,6 +18,7 @@ import (
"strings"
"testing"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/resources/images/imagetesting"
)
@@ -35,6 +36,7 @@ const goldenProcess = `
// Note, if you're enabling writeGoldenFiles on a MacOS ARM 64 you need to run the test with GOARCH=amd64, e.g.
func TestImagesGoldenFiltersMisc(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -111,6 +113,7 @@ Home.
func TestImagesGoldenFiltersMask(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -172,6 +175,7 @@ the last entry will win.
// Issue 13272, 13273.
func TestImagesGoldenFiltersMaskCacheIssues(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
}
@@ -348,6 +352,7 @@ Home.
func TestImagesGoldenProcessWebP(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -422,6 +427,7 @@ Home.
func TestImagesGoldenWebPAnimation(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -457,6 +463,7 @@ Home.
func TestImagesGoldenMethods(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -528,6 +535,7 @@ Home.
func TestImagesGoldenConfigLossyVsQuality(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
if imagetesting.SkipGoldenTests {
t.Skip("Skip golden test on this architecture")
@@ -21,6 +21,7 @@ import (
"strings"
"testing"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
)
@@ -97,6 +98,7 @@ func TestGetRemoteResponseHeaders(t *testing.T) {
func TestGetRemoteRetry(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
temporaryHTTPCodes := []int{408, 429, 500, 502, 503, 504}
numPages := 20
@@ -74,6 +74,7 @@ CSS: {{ $css.Content | safeCSS }}|
func TestTailwindCSSNoInlineImportsIssue13719(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
files := `
-- hugo.toml --
+4
View File
@@ -24,12 +24,15 @@ import (
"github.com/bep/logg"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/htesting"
qt "github.com/frankban/quicktest"
)
func TestGetCSV(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
c := qt.New(t)
for i, test := range []struct {
@@ -123,6 +126,7 @@ func TestGetCSV(t *testing.T) {
func TestGetJSON(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
c := qt.New(t)
for i, test := range []struct {
@@ -23,6 +23,7 @@ import (
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/hugolib"
)
@@ -247,6 +248,7 @@ ABCDE
}
func TestIncludeTimeout(t *testing.T) {
htesting.SkipSlowTestUnlessCI(t)
t.Parallel()
files := `
@@ -18,6 +18,7 @@ import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/hugolib"
)
@@ -509,6 +510,7 @@ Content: {{ .Content }}
// shortcodes in v0.141.0, replacing them with x and x_simple.
func TestXShortcodes(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
files := `
-- hugo.toml --
@@ -20,6 +20,7 @@ import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/resources/kinds"
"github.com/gohugoio/hugo/resources/page"
@@ -403,6 +404,7 @@ title: "P1"
func TestCreateManyTemplateStores(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
b := hugolib.Test(t, newSetupTestSites)
store := b.H.TemplateStore
@@ -1411,6 +1413,7 @@ layouts/list.html
func TestTemplateLoop(t *testing.T) {
t.Parallel()
htesting.SkipSlowTestUnlessCI(t)
files := `
-- hugo.toml --