]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
testing: Skip some slow tests when not running in CI
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 09:20:39 +0000 (10:20 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 14:38:49 +0000 (15:38 +0100)
Fixes #14438

14 files changed:
cache/filecache/filecache_test.go
htesting/test_helpers.go
hugolib/config_test.go
hugolib/hugo_sites_build_errors_test.go
hugolib/page_test.go
internal/js/esbuild/batch_integration_test.go
modules/client_test.go
resources/images/images_golden_integration_test.go
resources/resource_factories/create/create_integration_test.go
resources/resource_transformers/cssjs/tailwindcss_integration_test.go
tpl/data/data_test.go
tpl/partials/partials_integration_test.go
tpl/tplimpl/shortcodes_integration_test.go
tpl/tplimpl/templatestore_integration_test.go

index ed669933f25fe0529757bcc43eaa378576db9742..6b435597f7b787a887bdda377f16615b9f035fd5 100644 (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)
index 74e349424c310b3dd213e2cb949a52b706e8198a..384695df45a5fd51c288a7a38f53016b5d2c1adc 100644 (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") == ""
index 18d92fa6982238b47555c11ffd5a1359e87efe8d..2273c6afd0286dc01804df080ecee52c83cbafc5 100644 (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 := `
index 017f4d56f08fe78c551984d38ff3d3aa55724202..eecd86f8dcbca8b95a2cdbc5dbe73a7dcfdf41f0 100644 (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 --
 ---
index 939a9a82a02e67d40863a88fc82717505b08b273..903ee7fc703bdbd9b54ca9e48be44888a84e0af0 100644 (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 {
index b0a93cf09d0f11b802a6517a91ac4cc1df16df77..e61b7acd55ada7d43d6d08c230c75101bbc1454e 100644 (file)
@@ -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"]
index 26b9fcacdcafcfabd4b41ff130873521592d0d25..54e36be3a039932df5cd1d9fa610179995ec220a 100644 (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"
index 6b6b41e41944dfa1f98a729ef8af510658343ca6..ac147a287827dafc1c21161cffb27d6b690db753 100644 (file)
@@ -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")
index e8efc59eab2728fab513bbe41990e90667cc2259..acb511d6d0b25333a3d722797a4ecb0b8933b6bc 100644 (file)
@@ -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
index de78df51715e32281a1c0995dc18e14e3efedb31..01ad9fa946d332bc945b7f5b89da4032609d1e82 100644 (file)
@@ -74,6 +74,7 @@ CSS: {{ $css.Content | safeCSS }}|
 
 func TestTailwindCSSNoInlineImportsIssue13719(t *testing.T) {
        t.Parallel()
+       htesting.SkipSlowTestUnlessCI(t)
 
        files := `
 -- hugo.toml --
index d50c99384dd35af8810c1e872ef1dc611a36c09f..e2bdbee36e7a42eb5950282877f9f4bdff324105 100644 (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 {
index a7fee50cd7514aee96b14031af93c96b7d1bac9f..022d2474fcf228020440505895cefcf2450976fb 100644 (file)
@@ -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 := `
index d677d6e2d278735d712020b3b9e2710add8d0b30..ba6a63b22e0dfc36e2bc45ea17b9db783a30d0b8 100644 (file)
@@ -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 --
index 4c01ac3fd5e66a457787076abd8ced6ca560464a..6ba9cbbc472a0c33abb516fcbdc7ebc4ec8bb6d2 100644 (file)
@@ -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 --