From: Bjørn Erik Pedersen Date: Tue, 27 Jan 2026 09:20:39 +0000 (+0100) Subject: testing: Skip some slow tests when not running in CI X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5f5b2f378f51fe1c3a7e50f29f55b8e592b23e8a;p=brevno-suite%2Fhugo testing: Skip some slow tests when not running in CI Fixes #14438 --- diff --git a/cache/filecache/filecache_test.go b/cache/filecache/filecache_test.go index ed669933f..6b435597f 100644 --- a/cache/filecache/filecache_test.go +++ b/cache/filecache/filecache_test.go @@ -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) diff --git a/htesting/test_helpers.go b/htesting/test_helpers.go index 74e349424..384695df4 100644 --- a/htesting/test_helpers.go +++ b/htesting/test_helpers.go @@ -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") == "" diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 18d92fa69..2273c6afd 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -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 := ` diff --git a/hugolib/hugo_sites_build_errors_test.go b/hugolib/hugo_sites_build_errors_test.go index 017f4d56f..eecd86f8d 100644 --- a/hugolib/hugo_sites_build_errors_test.go +++ b/hugolib/hugo_sites_build_errors_test.go @@ -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 -- --- diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 939a9a82a..903ee7fc7 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -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 { diff --git a/internal/js/esbuild/batch_integration_test.go b/internal/js/esbuild/batch_integration_test.go index b0a93cf09..e61b7acd5 100644 --- a/internal/js/esbuild/batch_integration_test.go +++ b/internal/js/esbuild/batch_integration_test.go @@ -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"] diff --git a/modules/client_test.go b/modules/client_test.go index 26b9fcacd..54e36be3a 100644 --- a/modules/client_test.go +++ b/modules/client_test.go @@ -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" diff --git a/resources/images/images_golden_integration_test.go b/resources/images/images_golden_integration_test.go index 6b6b41e41..ac147a287 100644 --- a/resources/images/images_golden_integration_test.go +++ b/resources/images/images_golden_integration_test.go @@ -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") diff --git a/resources/resource_factories/create/create_integration_test.go b/resources/resource_factories/create/create_integration_test.go index e8efc59ea..acb511d6d 100644 --- a/resources/resource_factories/create/create_integration_test.go +++ b/resources/resource_factories/create/create_integration_test.go @@ -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 diff --git a/resources/resource_transformers/cssjs/tailwindcss_integration_test.go b/resources/resource_transformers/cssjs/tailwindcss_integration_test.go index de78df517..01ad9fa94 100644 --- a/resources/resource_transformers/cssjs/tailwindcss_integration_test.go +++ b/resources/resource_transformers/cssjs/tailwindcss_integration_test.go @@ -74,6 +74,7 @@ CSS: {{ $css.Content | safeCSS }}| func TestTailwindCSSNoInlineImportsIssue13719(t *testing.T) { t.Parallel() + htesting.SkipSlowTestUnlessCI(t) files := ` -- hugo.toml -- diff --git a/tpl/data/data_test.go b/tpl/data/data_test.go index d50c99384..e2bdbee36 100644 --- a/tpl/data/data_test.go +++ b/tpl/data/data_test.go @@ -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 { diff --git a/tpl/partials/partials_integration_test.go b/tpl/partials/partials_integration_test.go index a7fee50cd..022d2474f 100644 --- a/tpl/partials/partials_integration_test.go +++ b/tpl/partials/partials_integration_test.go @@ -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 := ` diff --git a/tpl/tplimpl/shortcodes_integration_test.go b/tpl/tplimpl/shortcodes_integration_test.go index d677d6e2d..ba6a63b22 100644 --- a/tpl/tplimpl/shortcodes_integration_test.go +++ b/tpl/tplimpl/shortcodes_integration_test.go @@ -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 -- diff --git a/tpl/tplimpl/templatestore_integration_test.go b/tpl/tplimpl/templatestore_integration_test.go index 4c01ac3fd..6ba9cbbc4 100644 --- a/tpl/tplimpl/templatestore_integration_test.go +++ b/tpl/tplimpl/templatestore_integration_test.go @@ -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 --