]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
all: Replace NewIntegrationTestBuilder with Test/TestE/TestRunning
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 3 Apr 2026 18:11:23 +0000 (20:11 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 3 Apr 2026 19:17:45 +0000 (21:17 +0200)
47 files changed:
cache/filecache/filecache_integration_test.go
config/allconfig/allconfig_integration_test.go
hugolib/config_test.go
hugolib/content_map_test.go
hugolib/filesystems/basefs_test.go
hugolib/frontmatter_test.go
hugolib/hugo_smoke_test.go
hugolib/hugolib_integration_test.go
hugolib/page__fragments_test.go
hugolib/page_test.go
hugolib/pagebundler_test.go
hugolib/pagecollections_test.go
hugolib/rebuild_test.go
hugolib/rendershortcodes_test.go
hugolib/renderstring_test.go
hugolib/resource_chain_test.go
hugolib/site_test.go
hugolib/template_test.go
internal/js/esbuild/batch_integration_test.go
markup/goldmark/codeblocks/codeblocks_integration_test.go
markup/goldmark/goldmark_integration_test.go
resources/page/page_integration_test.go
resources/page/permalinks_integration_test.go
resources/resource_factories/create/create_integration_test.go
resources/resource_transformers/babel/babel_integration_test.go
resources/resource_transformers/cssjs/postcss_integration_test.go
resources/resource_transformers/cssjs/tailwindcss_integration_test.go
resources/resource_transformers/js/js_integration_test.go
resources/resource_transformers/minifier/minifier_integration_test.go
resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
resources/resource_transformers/tocss/scss/scss_integration_test.go
resources/resources_integration_test.go
tpl/collections/collections_integration_test.go
tpl/debug/debug_integration_test.go
tpl/os/os_integration_test.go
tpl/os/os_test.go
tpl/page/page_integration_test.go
tpl/partials/partials_integration_test.go
tpl/resources/resources_integration_test.go
tpl/time/time_test.go
tpl/tplimpl/template_funcs_test.go
tpl/tplimpl/templatestore_integration_test.go
tpl/tplimpl/tplimpl_integration_test.go
tpl/transform/remarshal_test.go
tpl/transform/transform_integration_test.go
tpl/transform/transform_test.go
tpl/transform/unmarshal_test.go

index d17c4367bcd92fcdf6a503fcb8d090f41a9c9962..88873c740a5f2abbbf520f696b94c7d9c015d08e 100644 (file)
@@ -18,7 +18,6 @@ import (
        "testing"
        "time"
 
-       "github.com/bep/logg"
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/htesting"
        "github.com/gohugoio/hugo/hugolib"
@@ -39,9 +38,9 @@ title: "Home"
 
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t, TxtarString: files, RunGC: true, NeedsOsFS: true},
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+               c.RunGC = true
+       }))
 
        _, err := b.H.BaseFs.ResourcesCache.Stat(filepath.Join("_gen", "images"))
 
@@ -77,9 +76,9 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
 
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t, TxtarString: files, Running: true, RunGC: true, NeedsOsFS: true, LogLevel: logg.LevelInfo},
-       ).Build()
+       b := hugolib.TestRunning(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+               c.RunGC = true
+       }))
 
        b.Assert(b.GCCount, qt.Equals, 0)
        b.Assert(b.H, qt.IsNotNil)
index 6899cf21cc9e54c27baa51272d061ecc69ca8128..8bdfe76ac807dc0c9370b99a70cf580f20fa47aa 100644 (file)
@@ -43,9 +43,7 @@ title: "p1"
 Title: {{ .Title }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t, TxtarString: files},
-       ).Build()
+       b := hugolib.Test(t, files)
 
        // b.AssertFileContent("public/p1/index.html", "Title: p1")
 
@@ -81,9 +79,7 @@ baseURL = "https://example.com"
 logI18nWarnings = true
 logPathWarnings = true
 `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t, TxtarString: files},
-       ).Build()
+       b := hugolib.Test(t, files)
 
        conf := b.H.Configs.Base
 
index 0b3147bc33ca6b6cc4e9dc610c7dbed5c3974480..ae5efaf30fd2a5c81ebe7d6c583395ae2fbdd171 100644 (file)
@@ -125,12 +125,7 @@ weight = 1
 [languages.sv]
 weight = 2
 `
-               b, err := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).BuildE()
+               b, err := TestE(t, files)
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `default language "sv" is disabled`)
@@ -174,13 +169,9 @@ pm31: {{ .Site.Params.pm3.pm31 }}
 
 
 `
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               Environ:     []string{"HUGO_PARAMS_P2=p2env", "HUGO_PARAMS_PM2_PM21=pm21env", "HUGO_PARAMS_PM3_PM31=pm31env"},
-                       },
-               ).Build()
+               b := Test(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.Environ = []string{"HUGO_PARAMS_P2=p2env", "HUGO_PARAMS_PM2_PM21=pm21env", "HUGO_PARAMS_PM3_PM31=pm31env"}
+               }))
 
                b.AssertFileContent("public/index.html", "p1: p1base\np2: p2env\npm21: pm21env\npm22: pm22base\npm31: pm31env")
        })
@@ -254,14 +245,9 @@ Home.
                for i, v := range environ {
                        environ[i] = strings.ReplaceAll(v, " ", delim)
                }
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               Environ:     environ,
-                               BuildCfg:    BuildCfg{SkipRender: true},
-                       },
-               ).Build()
+               b := Test(t, files, TestOptSkipRender(), TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.Environ = environ
+               }))
 
                conf := b.H.Configs.Base
                b.Assert(conf.DisableLanguages, qt.DeepEquals, []string{"no", "sv"})
@@ -651,12 +637,7 @@ defaultMarkdownHandler = 'blackfriday'
 
 `
 
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNotNil)
        b.Assert(err.Error(), qt.Contains, "Configured defaultMarkdownHandler \"blackfriday\" not found. Did you mean to use goldmark? Blackfriday was removed in Hugo v0.100.0.")
@@ -692,12 +673,7 @@ themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
 
                        files := strings.ReplaceAll(filesTemplate, "hugo.toml", configName)
 
-                       b, err := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                               },
-                       ).BuildE()
+                       b, err := TestE(t, files)
 
                        b.Assert(err, qt.IsNil)
                        b.AssertFileContent("public/index.html",
@@ -743,13 +719,9 @@ Single.
                files = strings.ReplaceAll(files, "WEIGHT_SV", "2")
 
                cfg := config.New()
-               b, err := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               BaseCfg:     cfg,
-                       },
-               ).BuildE()
+               b, err := TestE(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.BaseCfg = cfg
+               }))
 
                b.Assert(err, qt.IsNil)
                b.AssertFileContent("public/index.html", "Home: en|2|")
@@ -762,13 +734,9 @@ Single.
 
                for range 20 {
                        cfg := config.New()
-                       b, err := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                                       BaseCfg:     cfg,
-                               },
-                       ).BuildE()
+                       b, err := TestE(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+                               c.BaseCfg = cfg
+                       }))
 
                        b.Assert(err, qt.IsNil)
                        b.AssertFileContent("public/index.html", "Home: en|2|")
@@ -801,12 +769,7 @@ Home.
 
 `
 
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNil)
        b.AssertFileContent("public/myindex.html", "Home.")
@@ -836,12 +799,7 @@ ThisIsAParam: {{ site.Params.thisIsAParam }}
 
 `
 
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNil)
        b.AssertFileContent("public/index.html", `
@@ -882,13 +840,7 @@ LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Lang
 {{ end }}
 
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               },
-       ).Build()
+       b := Test(t, files, TestOptWarn())
 
        b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 1)
 
@@ -936,13 +888,9 @@ func TestConfigHugoWorkingDir(t *testing.T) {
 WorkingDir: {{ hugo.WorkingDir }}|
 
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       WorkingDir:  "myworkingdir",
-               },
-       ).Build()
+       b := Test(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+               c.WorkingDir = "myworkingdir"
+       }))
 
        b.AssertFileContent("public/index.html", `
 WorkingDir: myworkingdir|
@@ -1009,12 +957,7 @@ Home
 
 `
 
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNil)
        b.AssertFileContent("public/index.html", `
@@ -1147,12 +1090,7 @@ Foo: {{ site.Params.foo }}|
 
 
        `
-               b, err := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).BuildE()
+               b, err := TestE(t, files)
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, "invalid language configuration ")
@@ -1174,12 +1112,7 @@ weight = 1
 
 
        `
-               b, err := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).BuildE()
+               b, err := TestE(t, files)
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `defaultContentLanguage "sv" not found in languages configuration`)
@@ -1339,14 +1272,9 @@ func TestLoadConfigYamlEnvVar(t *testing.T) {
                        env = defaultEnv
                }
 
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               Environ:     env,
-                               BuildCfg:    BuildCfg{SkipRender: true},
-                       },
-               ).Build()
+               b := Test(t, files, TestOptSkipRender(), TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.Environ = env
+               }))
 
                outputs := b.H.Configs.Base.Outputs
                if env == nil {
index 2f1f73a2cd986208d6f3cbe0d6a7ede1f20fe26f..6072c42569be07d35c619e27b622b465b8d77e0d 100644 (file)
@@ -210,11 +210,7 @@ Home: {{ .Title }}|
 
        `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           c,
-                       TxtarString: files,
-               }).Build()
+       b := Test(c, files)
 
        b.AssertFileContent("public/index.html", "Home: Integration Test|")
 }
index 5bc0393fe192fa00db9d2dcd6f5b06652975ca9c..883cf4d2859010a20422af7fca01322816d19d0e 100644 (file)
@@ -296,14 +296,9 @@ F1 text
 
        os.Chdir(wd)
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       WorkingDir:  tmpDir,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+               c.WorkingDir = tmpDir
+       }))
 
        bfs := b.H.BaseFs
        watchFilenames := bfs.WatchFilenames()
@@ -432,13 +427,9 @@ title: "Foo"
 ---
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       WorkingDir:  tempDir,
-                       TxtarString: files,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+               c.WorkingDir = tempDir
+       }))
 
        abs1 := filepath.Join(tempDir, "content", "foo.md")
        rel, abs2, err := b.H.BaseFs.AbsProjectContentDir("foo.md")
index 8b8937f49d0dbe45ad79bc70a96db38e9f9434f0..2f823e92997fbcd711bb07e4334c08a0814632b6 100644 (file)
@@ -31,14 +31,7 @@ Ints: {{ printf "%T" .Params.ints }} {{ range .Params.ints }}Int: {{ fmt.Printf
 Mixed: {{ printf "%T" .Params.mixed }} {{ range .Params.mixed }}Mixed: {{ fmt.Printf "%[1]v (%[1]T)" . }}|{{ end }}
 Strings: {{ printf "%T" .Params.strings }} {{ range .Params.strings }}Strings: {{ fmt.Printf "%[1]v (%[1]T)" . }}|{{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-
-       b.Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/post/one/index.html", "Ints: []interface {} Int: 1 (uint64)|Int: 2 (uint64)|Int: 3 (uint64)|")
        b.AssertFileContent("public/post/one/index.html", "Mixed: []interface {} Mixed: 1 (string)|Mixed: 2 (uint64)|Mixed: 3 (uint64)|")
index 2561b160d538cf055958b3d9d74816eab93b820b..284091db69f40fb0327cdd2f87194c44480b1faf 100644 (file)
@@ -38,13 +38,7 @@ title: Page
 Home: {{ .Title }}
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       // LogLevel:    logg.LevelTrace,
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 0)
        b.AssertFileContent("public/index.html", `Hello`)
@@ -508,13 +502,7 @@ Content Tag 1.
 
 `
 
-       b := NewIntegrationTestBuilder(IntegrationTestConfig{
-               T:           t,
-               TxtarString: files,
-               NeedsOsFS:   true,
-               // Verbose:     true,
-               // LogLevel:    logg.LevelTrace,
-       }).Build()
+       b := Test(t, files, TestOptOsFs())
 
        b.AssertFileContent("public/en/index.html",
                "Home: en|home|/en/|Home in English|<p>Home Content.</p>\n|HTML",
@@ -751,11 +739,7 @@ The content.
 
 // This is just a test to verify that BenchmarkBaseline is working as intended.
 func TestBenchmarkBaseline(t *testing.T) {
-       cfg := IntegrationTestConfig{
-               T:           t,
-               TxtarString: benchmarkBaselineFiles(true),
-       }
-       b := NewIntegrationTestBuilder(cfg).Build()
+       b := Test(t, benchmarkBaselineFiles(true))
 
        b.Assert(len(b.H.Sites), qt.Equals, 4)
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 161)
index 3d416c76c8b533c08d15ac9035d7e7f6343dacf3..c5570469a004e0b4011f137cc840abe07861d31b 100644 (file)
@@ -58,13 +58,7 @@ tags: ['T1']
 <ul>{{ range .AllTranslations }}<li>{{ .Title }}-{{ .Lang }}</li>{{ end }}</ul>
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files)
 
        // Kind home
        b.AssertFileContent("public/en/index.html",
@@ -98,14 +92,8 @@ func TestRenderStringBadMarkupOpt(t *testing.T) {
 {{ "something" | .RenderString $opts }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-
-       _, err := b.BuildE()
+       b, err := hugolib.TestE(t, files)
+       _ = b
 
        want := `no content renderer found for markup "foo"`
        if !strings.Contains(err.Error(), want) {
@@ -136,12 +124,6 @@ title: Films
 {{ (site.GetPage "/films").Title }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files)
        b.AssertFileContent("public/index.html", "tags\nfiction\nbooks\nFilms")
 }
index 0e4fd1c6056c2a4f449f34b679e5bc37dbc11672..4a6fe356d3c3b6a79fb754cf3f2d62971b2de5d0 100644 (file)
@@ -56,12 +56,7 @@ Fragments : {{ $p1.Fragments.Identifiers }}
        
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       TxtarString: files,
-                       T:           t,
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/en/p1/index.html", "HTML")
        b.AssertFileContent("public/en/p1/index.json", "ToC: <nav id=\"TableOfContents\">\n  <ul>\n    <li><a href=\"#heading-1-fr\">Heading 1 FR</a></li>\n  </ul>\n</nav>\nFragments : [heading-1-fr]")
@@ -98,12 +93,7 @@ Fragments: {{ .Fragments.Identifiers }}|
        
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       TxtarString: files,
-                       T:           t,
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/p1/index.html", "Fragments: [heading-p1-1 heading-p2-1 heading-p2-2]|")
        b.AssertFileContent("public/p2/index.html", "Fragments: [heading-p2-1 heading-p2-2]|")
index 245456b97c3abb820e25d814f4d0824f9845d546..1d34df54c153f2bd47ea9756d233b5fd8f20a32c 100644 (file)
@@ -378,14 +378,7 @@ allow = ['^python$', '^rst2html.*', '^asciidoctor$']
                        homePath := fmt.Sprintf("_index.%s", e.ext)
                        files.WriteString(fmt.Sprintf("-- content/%s --\n%s\n", homePath, homePage))
 
-                       b := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files.String(),
-                                       NeedsOsFS:   true,
-                                       BaseCfg:     cfg,
-                               },
-                       ).Build()
+                       b := Test(t, files.String(), TestOptOsFs(), TestOptWithConfig(func(c *IntegrationTestConfig) { c.BaseCfg = cfg }))
 
                        s := b.H.Sites[0]
 
@@ -412,13 +405,7 @@ baseURL = "http://example.com/"
 -- content/simple.md --
 ` + simplePageWithSummaryDelimiterAndMarkdownThatCrossesBorder + `
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
 
@@ -688,13 +675,7 @@ baseURL = "http://example.com/"
 -- content/tocpage.md --
 ` + pageWithToC + `
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
 
@@ -1069,13 +1050,7 @@ baseURL = "http://example.com/"
 -- content/simple.md --
 ` + simplePageRFC3339Date + `
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
 
@@ -1109,13 +1084,7 @@ date = ["` + dateHandler + `", "date"]
 -- content/section/2012-02-22-slug.md --
 ` + fmt.Sprintf(pageTemplate, 2, "slug: aslug") + `
 `
-                       b := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                                       NeedsOsFS:   true, // Needed for fileModTime
-                               },
-                       ).Build()
+                       b := Test(t, files, TestOptOsFs())
 
                        s := b.H.Sites[0]
                        b.Assert(len(s.RegularPages()), qt.Equals, 2)
@@ -1277,13 +1246,7 @@ post = ":year/:month/:day/:title/"
 -- content/` + test.path + ` --
 ` + test.content + `
 `
-                       b := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                                       BuildCfg:    BuildCfg{SkipRender: true},
-                               },
-                       ).Build()
+                       b := Test(t, files, TestOptSkipRender())
 
                        s := b.H.Sites[0]
                        b.Assert(len(s.RegularPages()), qt.Equals, 1)
@@ -1469,13 +1432,7 @@ baseURL = "http://example.com/"
 -- content/simple.md --
 ` + utf8BOM + simplePage + `
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
 
@@ -1745,13 +1702,7 @@ title: Scratch Me!
 
 {{< scratch >}}
 `
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNil)
 
@@ -1824,13 +1775,7 @@ author = "Jo Nesbø"
 
 +++
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html",
                "Author page: Ernest Miller Hemingway",
@@ -1894,13 +1839,7 @@ T-SHORT
 -- content/page.md --
 ` + content + `
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/page/index.html",
                `<nav id="TableOfContents">
@@ -1932,10 +1871,7 @@ title: "p2"
 ---
 `
 
-       b := NewIntegrationTestBuilder(IntegrationTestConfig{
-               T:           t,
-               TxtarString: files,
-       }).Build()
+       b := Test(t, files)
 
        p1 := b.H.Sites[0].RegularPages()[0]
        p2 := b.H.Sites[0].RegularPages()[1]
@@ -1957,12 +1893,7 @@ func TestRenderWithoutArgument(t *testing.T) {
 {{ .Render }}
 `
 
-       b, err := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := TestE(t, files)
 
        b.Assert(err, qt.IsNotNil)
 }
index 0ea695366f325a50ee37939d2d24a3a92a8937fe..ee9808f4b0aee9a7b3276fd3953c944241ca5155 100644 (file)
@@ -332,13 +332,7 @@ headless: true
 HEADLESS1: {{ $headless1.Title }}|{{ $headless1.RelPermalink }}|{{ len $headless1.Resources }}|
 HEADLESS2: {{ $headless2.Title }}{{ $headless2.RelPermalink }}|{{ len $headless2.Resources }}|
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 HEADLESS1: My Headless Bundle1||1|
index 31af5526086d645f323327b77913827b28eb349c..dc43c986c1dcb702a162299c5adef0b2341bef20 100644 (file)
@@ -584,13 +584,7 @@ Single.
 /README.md: {{ with .GetPage "/README.md" }}{{ .Title }}{{ end }}|
 {{ .Content }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html",
                `
@@ -649,13 +643,7 @@ title: about1en
 NOT FOUND
 {{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `Docs p1: p1`)
        b.AssertFileContent("public/en/index.html", `NOT FOUND`)
@@ -713,13 +701,7 @@ title: news1
 
 Sect1 RegularPagesRecursive: {{ range $sect1.RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 Sect1 RegularPagesRecursive: page:/docs/sect1/ps1/|page:/docs/sect1/ps2/|page:/docs/sect1/sect1_s2/ps2_1/||End.
@@ -737,11 +719,7 @@ func TestRegularPagesRecursiveHome(t *testing.T) {
 RegularPagesRecursive: {{ range .RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               }).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `RegularPagesRecursive: page:/p1/|page:/post/p2/||End.`)
 }
index d61e94a5afc108a2d9b362b9b75869d777b79907..d05ef753805bd562f83242ccd62a3e9070178244 100644 (file)
@@ -7,7 +7,6 @@ import (
        "testing"
        "time"
 
-       "github.com/bep/logg"
        "github.com/fortytw2/leaktest"
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/common/types"
@@ -986,18 +985,12 @@ Codeblock Include: {{ .Title }}|
 
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       Running:     true,
-                       Verbose:     false,
-                       BuildCfg: BuildCfg{
-                               testCounters: &buildCounters{},
-                       },
-                       LogLevel: logg.LevelWarn,
-               },
-       ).Build()
+       b := TestRunning(t, files,
+               TestOptWarn(),
+               TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.BuildCfg = BuildCfg{testCounters: &buildCounters{}}
+               }),
+       )
 
        // When running the server, this is done on shutdown.
        // Do this here to satisfy the leak detector above.
@@ -1331,18 +1324,11 @@ Content: {{ .Content }}|
 
        testCounters := &buildCounters{}
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       Running:     true,
-                       // LogLevel:    logg.LevelTrace,
-                       // Verbose:     true,
-                       BuildCfg: BuildCfg{
-                               testCounters: testCounters,
-                       },
-               },
-       ).Build()
+       b := TestRunning(t, files,
+               TestOptWithConfig(func(c *IntegrationTestConfig) {
+                       c.BuildCfg = BuildCfg{testCounters: testCounters}
+               }),
+       )
 
        b.AssertFileContent("public/index.html", `<script src="/main.js"></script>`)
        b.AssertFileContent("public/p1/index.html", "<script>\n\"console.log(\\\"Hello\\\");\"\n</script>")
@@ -1502,15 +1488,9 @@ console.log("Hello");
 foo();
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       Running:     true,
-                       // LogLevel:    logg.LevelTrace,
-                       NeedsOsFS: true,
-               },
-       ).Build()
+       b := TestRunning(t, files,
+               TestOptOsFs(),
+       )
 
        b.AssertFileContent("public/index.html", "Home.", "Hello", "Foo")
        // Edit the imported file.
@@ -1585,16 +1565,10 @@ Single.
 {{ end }}
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:               t,
-                       TxtarString:     files,
-                       Running:         true,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       // LogLevel:        logg.LevelDebug,
-               },
-       ).Build()
+       b := TestRunning(t, files,
+               TestOptOsFs(),
+               TestOptWithNpmInstall(),
+       )
 
        b.AssertFileContent("public/index.html", "Home.", "<style>body {\n\tbackground: red;\n}</style>")
        b.AssertFileContent("public/p1/index.html", "Single.", "/css/main.css")
@@ -1748,14 +1722,9 @@ Home.
        runTest := func(transpiler string) {
                t.Run(transpiler, func(t *testing.T) {
                        files := strings.Replace(filesTemplate, "TRANSPILER", transpiler, 1)
-                       b := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                                       Running:     true,
-                                       NeedsOsFS:   true,
-                               },
-                       ).Build()
+                       b := TestRunning(t, files,
+                               TestOptOsFs(),
+                       )
 
                        b.AssertFileContent("public/index.html", "Home.", "background: red")
 
index 9c2966d5b2d66cd3adcaba893816d92c8e10fb31..e952e258f4a17c0f4fe86d82a291f5a6d52e4d70 100644 (file)
@@ -189,13 +189,7 @@ Myshort Original.
 
 `
 
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       Running:     true,
-               },
-       ).Build()
+       b := TestRunning(t, files)
 
        b.AssertNoRenderShortcodesArtifacts()
        b.AssertFileContent("public/p1/index.html", "Original")
index 6d2aace749d440b507f7821edc3dfe3617aeec3d..adf2771f75313534d6fde07e6c0200cf00f7b7e4 100644 (file)
@@ -125,12 +125,7 @@ HasShortcode: foo:{{ .HasShortcode "foo" }}:false
 `
 
        t.Run("Basic", func(t *testing.T) {
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: filesTemplate,
-                       },
-               ).Build()
+               b := Test(t, filesTemplate)
 
                b.AssertFileContent("public/p1/index.html",
                        "<p>Markdown: 1. Item Mark2 1</p>\n<ol>\n<li>Item Mark2 2\n<ol>\n<li>Item Mark2 2-1</li>\n</ol>\n</li>\n<li>Item Mark2 3|",
@@ -145,13 +140,7 @@ Page Type: *hugolib.pageForShortcode`,
        })
 
        t.Run("Edit shortcode", func(t *testing.T) {
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: filesTemplate,
-                               Running:     true,
-                       },
-               ).Build()
+               b := TestRunning(t, filesTemplate)
 
                b.EditFiles("layouts/_shortcodes/myhthml.html", "Edit shortcode").Build()
 
index ba6f30d7691a155fffc851beb06c8c5dabb653b7..efc18147a482feca52a6c49fda1f8e3e56296d9b 100644 (file)
@@ -1330,12 +1330,7 @@ Template test.
                        files := test.files
                        files = strings.ReplaceAll(files, "HTTPTEST_SERVER_URL", ts.URL)
 
-                       b := NewIntegrationTestBuilder(
-                               IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                               },
-                       ).Build()
+                       b := Test(t, files)
 
                        test.assert(b)
                })
index dc9f141488eba03555c08eb786e5b22faa6b4062..9909d5b55e8c6e4a2d6aab0314ca857560ef11a4 100644 (file)
@@ -66,12 +66,7 @@ publishdate: "2012-05-29"
 baseURL = "http://auth/bub"
 ` + basefiles
 
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
                b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
        })
 
@@ -82,12 +77,7 @@ baseURL = "http://auth/bub"
 baseURL = "http://auth/bub"
 buildDrafts = true
 ` + basefiles
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
                b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 2)
        })
 
@@ -98,12 +88,7 @@ buildDrafts = true
 baseURL = "http://auth/bub"
 buildFuture = true
 ` + basefiles
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
                b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 2)
        })
 
@@ -115,12 +100,7 @@ baseURL = "http://auth/bub"
 buildDrafts = true
 buildFuture = true
 ` + basefiles
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
                b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 4)
        })
 }
@@ -198,13 +178,7 @@ weight: 3
 # doc5
 *some content*
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(b.H.Sites[0].Lastmod().IsZero(), qt.Equals, false)
        b.Assert(b.H.Sites[0].Lastmod().Year(), qt.Equals, 2017)
@@ -226,13 +200,7 @@ date: 2014-05-29
 # doc1
 *some content*
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{SkipRender: true},
-               },
-       ).Build()
+       b := Test(t, files, TestOptSkipRender())
 
        b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
 }
@@ -275,12 +243,7 @@ doc2 *content*
 baseURL = "http://auth/bub"
 uglyURLs = true
 ` + basefiles
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
 
                b.AssertFileContent("public/index.html", "Home Sweet Home.")
                b.AssertFileContent("public/sect/doc1.html", "<h1 id=\"title\">title</h1>\n<p>some <em>content</em></p>\n")
@@ -301,12 +264,7 @@ uglyURLs = true
 baseURL = "http://auth/bub"
 uglyURLs = false
 ` + basefiles
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := Test(t, files)
 
                b.AssertFileContent("public/index.html", "Home Sweet Home.")
                b.AssertFileContent("public/sect/doc1/index.html", "<h1 id=\"title\">title</h1>\n<p>some <em>content</em></p>\n")
index 90b8a575af67366348b6a6f762415b0b7b6abb57..257964d5adf722c0e1a81ba224da7444617678f8 100644 (file)
@@ -40,13 +40,7 @@ title: "Page"
 
 Page Content
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/page/index.html", "Base: Hi!?")
 }
@@ -115,13 +109,7 @@ baseURL = "http://example.com/"
 title: The Page
 ---
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/blog/p1/index.html", `single`)
        b.AssertFileContent("public/blog/index.html", `list`)
@@ -142,13 +130,7 @@ Base: {{ block "main" . }}{{ end }}
   Bonjour
 {{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `Base:
 Bonjour`)
@@ -174,13 +156,7 @@ title: Home Sweet Home
 title: P1
 ---
 `
-               b := NewIntegrationTestBuilder(
-                       IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               BuildCfg:    BuildCfg{},
-                       },
-               ).Build()
+               b := Test(t, files)
 
                b.AssertFileContent("public/index.html", `List: Home Sweet Home`)
                b.AssertFileContent("public/p1/index.html", `Single: P1`)
@@ -222,13 +198,7 @@ Baseof mysection: {{ block "main" .  }}mysection block{{ end }}
 title: My Page
 ---
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/en/index.html", `Baseof en: Main Home En`)
        b.AssertFileContent("public/fr/index.html", `Baseof fr: Main Home Fr`)
@@ -261,13 +231,7 @@ Site: {{ site.Language.Lang }} / {{ .Site.Language.Lang }} / {{ site.BaseURL }}
 Sites: {{ site.Sites.Default.Home.Language.Lang }}
 Hugo: {{ hugo.Generator }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/en/index.html",
                "Site: en / en / http://example.com/blog",
@@ -309,13 +273,7 @@ dollarContext: 60: {{ partial "dollarContext.tpl" 18 }}
 adder: 70: {{ partial "dict.tpl" (dict "adder" 28) }}
 complex: 80: {{ partial "complex.tpl" 38 }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 add42: 50: 50
@@ -344,13 +302,7 @@ X{{ partial "retval" 0 }}X
 {{ end }}
 -- content/p.md --
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html",
                `
@@ -377,13 +329,7 @@ Partial cached3: {{ partialCached "p1" "input3" $key2 }}
 -- layouts/_partials/p1.html --
 partial: {{ . }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
  Partial cached1: partial: input1
@@ -415,13 +361,7 @@ with: Zero {{ with $zero }}FAIL{{ else }}OK{{ end }}
 title: p1
 ---
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 if: Zero: OK
@@ -461,13 +401,7 @@ Population in Norway is {{
        | upper
 }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 <script type="application/ld+json">{"@type":"WebPage","headline":"a \u0026 b"}</script>
@@ -497,13 +431,7 @@ P2: {{ $p2 }}
 {{ return $value }}
 {{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html",
                `
@@ -541,13 +469,7 @@ P2: {{ $p2 }}
 {{ return $value }}
 {{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html",
                `
@@ -585,13 +507,7 @@ This is home main
 This is single main
 {{ end }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `
 Home Header
@@ -619,13 +535,7 @@ baseURL = "http://example.com/"
 {{ $a := apply $b "strings.Trim" "." " " }}
 a: {{ $a }}
 `
-       b := NewIntegrationTestBuilder(
-               IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       BuildCfg:    BuildCfg{},
-               },
-       ).Build()
+       b := Test(t, files)
 
        b.AssertFileContent("public/index.html", `a: [a b c]`)
 }
index e61b7acd55ada7d43d6d08c230c75101bbc1454e..e29eaf9c1547962dc4960d0874542eeb59320244 100644 (file)
@@ -22,7 +22,6 @@ import (
 
        qt "github.com/frankban/quicktest"
 
-       "github.com/bep/logg"
        "github.com/gohugoio/hugo/common/paths"
        "github.com/gohugoio/hugo/htesting"
        "github.com/gohugoio/hugo/hugolib"
@@ -679,16 +678,7 @@ Home.
  
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               t,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       TxtarString:     files,
-                       Running:         true,
-                       LogLevel:        logg.LevelWarn,
-                       // PrintAndKeepTempDir: true,
-               }).Build()
+       b := hugolib.TestRunning(t, files, hugolib.TestOptWithOSFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptWarn())
 
        b.AssertFileContent("public/index.html",
                "mains: 0: /mybundle/mains.js",
index 1eb88d34d2f886ee7eb06aab3f5df36a4f595993..c3808359dcdf49e18b3858815f4b1e164a98d25a 100644 (file)
@@ -291,12 +291,7 @@ Attributes: {{ .Attributes }}|Options: {{ .Options }}|
 
 `
        testLanguage := func(language, expect string) {
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: strings.ReplaceAll(files, "LANGUAGE", language),
-                       },
-               ).Build()
+               b := hugolib.Test(t, strings.ReplaceAll(files, "LANGUAGE", language))
 
                b.AssertFileContent("public/p1/index.html", expect)
        }
@@ -339,12 +334,7 @@ Common
        } {
                t.Run(test.name, func(t *testing.T) {
                        t.Parallel()
-                       b := hugolib.NewIntegrationTestBuilder(
-                               hugolib.IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: strings.ReplaceAll(files, "BLOCK", test.markdown),
-                               },
-                       ).Build()
+                       b := hugolib.Test(t, strings.ReplaceAll(files, "BLOCK", test.markdown))
 
                        b.AssertFileContent("public/p1/index.html", "Common")
                })
@@ -376,12 +366,7 @@ Hello, World!
 Attributes: {{ .Attributes }}|Type: {{ .Type }}|
 `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := hugolib.TestE(t, files)
 
        b.Assert(err, qt.Not(qt.IsNil))
        b.Assert(err.Error(), qt.Contains, "p1.md:7:9\": failed to parse Markdown attributes; you may need to quote the values")
index ca750de45a9e1771b9de9aabf99617c5e9e0bd26..1f7cff8b3689b976ff97a91e8b341883c4a75f84 100644 (file)
@@ -384,12 +384,7 @@ a@b.com
 
                        files = strings.ReplaceAll(files, "RENDERFUNC", renderFunc)
 
-                       b, err := hugolib.NewIntegrationTestBuilder(
-                               hugolib.IntegrationTestConfig{
-                                       T:           t,
-                                       TxtarString: files,
-                               },
-                       ).BuildE()
+                       b, err := hugolib.TestE(t, files)
 
                        b.Assert(err, qt.IsNotNil)
                        b.Assert(err.Error(), qt.Contains, "text is already rendered, repeating it may cause infinite recursion")
@@ -449,12 +444,7 @@ Link https procol: https://www.example.org
 <a href="{{ .Destination | safeURL }}">{{ .Text }}</a>`
                }
 
-               return hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               return hugolib.Test(t, files)
        }
 
        for _, withHook := range []bool{false, true} {
index 79580f75839d3185a45d32be5bd61e3069152ab0..6ec224f936f162b9305274048219453c20d7240d 100644 (file)
@@ -59,12 +59,7 @@ date: "2020-02-01"
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/en/index.html", "0|February, 2020|Pages(1)1|January, 2020|Pages(1)")
        b.AssertFileContent("public/fr/index.html", "0|février, 2020|Pages(1)1|janvier, 2020|Pages(1)")
@@ -117,12 +112,7 @@ ByWeight: {{ range site.RegularPages.ByWeight }}{{ .Title }}|{{ end }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/en/index.html", `
 ByTitle: alpha|émotion|zulu|
index 9406d133c568b783ed6d4723051b470b363b7e07..08fefeb7cbb0c48de77b1596ca3a955185e85128 100644 (file)
@@ -112,12 +112,7 @@ slug: "mytagslug"
 
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWarn())
 
        t.Log(b.LogString())
        // No .File.TranslationBaseName on zero object etc. warnings.
@@ -168,12 +163,7 @@ slug: "p1slugvalue"
 
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWarn())
 
        t.Log(b.LogString())
        // No .File.TranslationBaseName on zero object etc. warnings.
@@ -221,12 +211,7 @@ Single.
 List.
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWarn())
 
        t.Log(b.LogString())
        // No .File.TranslationBaseName on zero object etc. warnings.
@@ -270,12 +255,7 @@ Single.
 List.
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWarn())
 
        t.Log(b.LogString())
        // No .File.TranslationBaseName on zero object etc. warnings.
@@ -311,12 +291,7 @@ title: Recipe 2
 slug: custom-recipe-2
 ---
 `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelWarn,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptWarn())
 
        t.Log(b.LogString())
        b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 0)
index e210915efd1bca14a2ff9982de4865ca5cd524e7..897055432fd76f5a763b0b45dc0af958c66bf65a 100644 (file)
@@ -47,14 +47,7 @@ func TestGetRemoteHead(t *testing.T) {
 {{ end }}
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-
-       b.Build()
+       b := hugolib.Test(t, files)
 
        b.AssertFileContent("public/index.html",
                "Head Content: .",
@@ -83,14 +76,7 @@ func TestGetRemoteResponseHeaders(t *testing.T) {
 {{ end }}
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-
-       b.Build()
+       b := hugolib.Test(t, files)
 
        b.AssertFileContent("public/index.html",
                "Response Headers: map[Server:[Netlify] X-Frame-Options:[DENY]]",
@@ -147,14 +133,7 @@ mediaTypes = ['text/plain']
 
        t.Run("OK", func(t *testing.T) {
                files := strings.ReplaceAll(filesTemplate, "TIMEOUT", "60s")
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               )
-
-               b.Build()
+               b := hugolib.Test(t, files)
 
                for i := range numPages {
                        b.AssertFileContent(fmt.Sprintf("public/post/p%d/index.html", i), fmt.Sprintf("Content: Response for /post/p%d/.", i))
@@ -163,12 +142,7 @@ mediaTypes = ['text/plain']
 
        t.Run("Timeout", func(t *testing.T) {
                files := strings.ReplaceAll(filesTemplate, "TIMEOUT", "100ms")
-               b, err := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).BuildE()
+               b, err := hugolib.TestE(t, files)
                // This is hard to get stable on GitHub Actions, it sometimes succeeds due to timing issues.
                if err != nil {
                        b.AssertLogContains("Got Err")
@@ -209,13 +183,7 @@ mediaTypes = ['text/plain']
 `
        files = strings.ReplaceAll(files, "URL", srv.URL)
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files)
 
        // The per-request timeout of 200ms should fire well before the global 30s timeout.
        b.AssertFileContent("public/index.html", "Err:")
@@ -257,13 +225,7 @@ mediaTypes = ['text/plain']
 `
        files = strings.ReplaceAll(files, "URL", srv.URL)
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files)
 
        b.AssertFileContent("public/index.html", "Content: Hello from remote.")
 }
index c08114b6c93c3171f551ef5b01c645f6bf951925..1153c775d8263ff4d52c07c86a663bd644777e58 100644 (file)
@@ -16,7 +16,6 @@ package babel_test
 import (
        "testing"
 
-       "github.com/bep/logg"
        "github.com/gohugoio/hugo/htesting"
        "github.com/gohugoio/hugo/hugolib"
 )
@@ -75,14 +74,7 @@ Transpiled3: {{ $transpiled.Permalink }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               t,
-                       TxtarString:     files,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       LogLevel:        logg.LevelInfo,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
 
        b.AssertLogContains("babel: Hugo Environment: production")
        b.AssertFileContent("public/index.html", `var Car2 =`)
index 5ddae9070a7debfa43a4137ee0c4ef5348f2c9d2..02707fd5f4a080520d03b9596533b9f83a636823 100644 (file)
@@ -20,7 +20,6 @@ import (
        "strings"
        "testing"
 
-       "github.com/bep/logg"
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/common/herrors"
        "github.com/gohugoio/hugo/htesting"
@@ -120,15 +119,9 @@ func TestTransformPostCSS(t *testing.T) {
 
                files := repl.Replace(postCSSIntegrationTestFiles)
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:               c,
-                               NeedsOsFS:       true,
-                               NeedsNpmInstall: true,
-                               LogLevel:        logg.LevelInfo,
-                               WorkingDir:      tempDir,
-                               TxtarString:     files,
-                       }).Build()
+               b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+                       cfg.WorkingDir = tempDir
+               }))
 
                b.AssertFileContent("public/index.html", `
 Styles RelPermalink: /foo/css/styles.css
@@ -155,13 +148,7 @@ func TestTransformPostCSSError(t *testing.T) {
 
        c := qt.New(t)
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               c,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       TxtarString:     strings.ReplaceAll(postCSSIntegrationTestFiles, "color: blue;", "@apply foo;"), // Syntax error
-               }).BuildE()
+       b, err := hugolib.TestE(c, strings.ReplaceAll(postCSSIntegrationTestFiles, "color: blue;", "@apply foo;"), hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall())
 
        ferrs := herrors.UnwrapFileErrors(err)
        b.Assert(len(ferrs), qt.Equals, 2)
@@ -175,12 +162,7 @@ func TestTransformPostCSSNotInstalledError(t *testing.T) {
 
        c := qt.New(t)
 
-       _, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           c,
-                       NeedsOsFS:   true,
-                       TxtarString: postCSSIntegrationTestFiles,
-               }).BuildE()
+       _, err := hugolib.TestE(c, postCSSIntegrationTestFiles, hugolib.TestOptOsFs())
 
        ferrs := herrors.UnwrapFileErrors(err)
        c.Assert(len(ferrs), qt.Equals, 1)
@@ -195,14 +177,7 @@ func TestTransformPostCSSImportError(t *testing.T) {
 
        c := qt.New(t)
 
-       _, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               c,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       LogLevel:        logg.LevelInfo,
-                       TxtarString:     strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`),
-               }).BuildE()
+       _, err := hugolib.TestE(c, strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`), hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
        ferrs := herrors.UnwrapFileErrors(err)
        c.Assert(len(ferrs), qt.Equals, 2)
        c.Assert(err.Error(), qt.Contains, "styles.css:4:3")
@@ -219,14 +194,7 @@ func TestTransformPostCSSImporSkipInlineImportsNotFound(t *testing.T) {
        files := strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`)
        files = strings.ReplaceAll(files, `{{ $options := dict "inlineImports" true }}`, `{{ $options := dict "inlineImports" true "skipInlineImportsNotFound" true }}`)
 
-       s := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               c,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       LogLevel:        logg.LevelInfo,
-                       TxtarString:     files,
-               }).Build()
+       s := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
 
        s.AssertFileContent("public/css/styles.css", `@import "components/doesnotexist.css";`)
 }
@@ -250,15 +218,9 @@ func TestTransformPostCSSResourceCacheWithPathInBaseURL(t *testing.T) {
                        files = strings.ReplaceAll(files, "useResourceCacheWhen = 'never'", "   useResourceCacheWhen = 'always'")
                }
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:               c,
-                               NeedsOsFS:       true,
-                               NeedsNpmInstall: true,
-                               LogLevel:        logg.LevelInfo,
-                               TxtarString:     files,
-                               WorkingDir:      tempDir,
-                       }).Build()
+               b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+                       cfg.WorkingDir = tempDir
+               }))
 
                b.AssertFileContent("public/index.html", `
 Styles Content: Len: 770917
index 01ad9fa946d332bc945b7f5b89da4032609d1e82..e2ce293e3a82412badf3a6679bca84213c1134e7 100644 (file)
@@ -16,7 +16,6 @@ package cssjs_test
 import (
        "testing"
 
-       "github.com/bep/logg"
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/htesting"
        "github.com/gohugoio/hugo/hugolib"
@@ -60,14 +59,7 @@ func TestTailwindV4Basic(t *testing.T) {
 CSS: {{ $css.Content | safeCSS }}|
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               t,
-                       TxtarString:     files,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       LogLevel:        logg.LevelInfo,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
 
        b.AssertFileContent("public/index.html", "/*! tailwindcss v4.")
 }
@@ -122,14 +114,7 @@ target = 'assets/css'
 }
 `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               t,
-                       TxtarString:     files,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       LogLevel:        logg.LevelInfo,
-               }).BuildE()
+       b, err := hugolib.TestE(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
 
        b.Assert(err, qt.IsNotNil)
        b.Assert(err.Error(), qt.Contains, "Can't resolve 'colors/red.css'")
index ee84ee752e3dcd4091172cd3b0c57c2b5c4c80de..a11a6fbe9fd4acbe427c20b49f36890d493cf8a7 100644 (file)
@@ -56,13 +56,13 @@ JS Content:{{ $js.Content }}:End:
                        `
 
        c.Run("Basic", func(c *qt.C) {
-               b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+               b := hugolib.Test(c, mainWithImport, hugolib.TestOptOsFs())
 
                b.AssertFileContent("public/index.html", `abcd`)
        })
 
        c.Run("Edit Import", func(c *qt.C) {
-               b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, Running: true, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+               b := hugolib.Test(c, mainWithImport, hugolib.TestOptRunning(), hugolib.TestOptOsFs())
 
                b.AssertFileContent("public/index.html", `abcd`)
                b.EditFileReplaceFunc("assets/js/util1.js", func(s string) string { return strings.ReplaceAll(s, "abcd", "1234") }).Build()
@@ -70,7 +70,7 @@ JS Content:{{ $js.Content }}:End:
        })
 
        c.Run("Edit Import Nested", func(c *qt.C) {
-               b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, Running: true, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+               b := hugolib.Test(c, mainWithImport, hugolib.TestOptRunning(), hugolib.TestOptOsFs())
 
                b.AssertFileContent("public/index.html", `efgh`)
                b.EditFileReplaceFunc("assets/js/util2.js", func(s string) string { return strings.ReplaceAll(s, "efgh", "1234") }).Build()
@@ -106,14 +106,9 @@ require github.com/gohugoio/hugoTestProjectJSModImports v0.10.0 // indirect
 }
 
 `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               c,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       TxtarString:     files,
-                       Verbose:         true,
-               }).Build()
+       b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+               cfg.Verbose = true
+       }))
 
        b.AssertFileContent("public/js/main.js", `
 greeting: "greeting configured in mod2"
@@ -196,13 +191,7 @@ TS2: {{ template "print" $ts2 }}
 }
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:               c,
-                       NeedsOsFS:       true,
-                       NeedsNpmInstall: true,
-                       TxtarString:     files,
-               }).Build()
+       b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall())
 
        b.AssertFileContent("public/js/main.js", `//# sourceMappingURL=main.js.map`)
        b.AssertFileContent("public/js/main.js.map", `"version":3`, "! ns-hugo")                                   // linked
@@ -266,7 +255,7 @@ JS Content:{{ $js.Content }}:End:
        c.Run("Import from main not found", func(c *qt.C) {
                c.Parallel()
                files := strings.Replace(filesTemplate, "import { hello1, hello2 }", "import { hello1, hello2, FOOBAR }", 1)
-               b, err := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: files}).BuildE()
+               b, err := hugolib.TestE(c, files, hugolib.TestOptOsFs())
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `main.js:2:25": No matching export`)
        })
@@ -274,7 +263,7 @@ JS Content:{{ $js.Content }}:End:
        c.Run("Import from import not found", func(c *qt.C) {
                c.Parallel()
                files := strings.Replace(filesTemplate, "import { hello3 } from './util2';", "import { hello3, FOOBAR } from './util2';", 1)
-               b, err := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: files}).BuildE()
+               b, err := hugolib.TestE(c, files, hugolib.TestOptOsFs())
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `util1.js:4:17": No matching export in`)
        })
@@ -304,12 +293,7 @@ import 'imp3/foo.js';
 
                        files = strings.ReplaceAll(files, "IMPORT_SRC_DIR", importSrcDir)
 
-                       b := hugolib.NewIntegrationTestBuilder(
-                               hugolib.IntegrationTestConfig{
-                                       T:           c,
-                                       NeedsOsFS:   true,
-                                       TxtarString: files,
-                               }).Build()
+                       b := hugolib.Test(c, files, hugolib.TestOptOsFs())
 
                        expected := `
 IMPORT_SRC_DIR:imp1/index.js
@@ -348,12 +332,7 @@ console.log("Hello 2");
 {{ $js.RelPermalink }}
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       NeedsOsFS:   true,
-                       TxtarString: files,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/js/main.js", `
 License util1
@@ -383,12 +362,7 @@ class A {}
 {{ $opts := dict "target" "es2020" "targetPath" "js/main.js" }}
 {{ (resources.Get "ts/main.ts" | js.Build $opts).Publish }}
 `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       NeedsOsFS:   true,
-                       TxtarString: files,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
        b.AssertFileContent("public/js/main.js", "__decorateClass")
 }
 
index 656f4bb885bca4d3422377e5062c4916c361c15e..f775268186b21b4bf78f55394db29d1577ec62f0 100644 (file)
@@ -35,12 +35,7 @@ new Date(2002, 04, 11)
 </script>
 `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           c,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := hugolib.TestE(c, files)
 
        b.Assert(err, qt.IsNotNil)
        b.Assert(err, qt.ErrorMatches, "(?s).*legacy octal numbers.*line 1.*")
index 2301bd7087e4e72245bb08241a0d1c79f5e1ae41..81591be71ac15d7c2d284c0b41a55ee86041d53d 100644 (file)
@@ -17,7 +17,6 @@ import (
        "strings"
        "testing"
 
-       "github.com/bep/logg"
        qt "github.com/frankban/quicktest"
        "github.com/gohugoio/hugo/common/herrors"
        "github.com/gohugoio/hugo/htesting"
@@ -47,12 +46,7 @@ moo {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: moo{color:#fff}`)
 }
@@ -88,13 +82,7 @@ T1: {{ $r.Content | safeHTML }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        // Dart Sass does not follow regular CSS import, but they
        // get pulled to the top.
@@ -132,13 +120,7 @@ T1: {{ $r.Content | safeHTML }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", "T1: #main {\n  color: blue;\n}\n\n/* foo */")
 }
@@ -179,13 +161,7 @@ target = 'assets'
 source = 'foo'
 target = 'assets/foo'
        `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `
                @import "import-this-file.css";
@@ -255,13 +231,7 @@ zoo {
 @import "components/imports";
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: moo{color:#ccc}boo{color:green}zoo{color:pink}`)
 }
@@ -285,13 +255,7 @@ disableKinds = ["term", "taxonomy", "section", "page"]
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       LogLevel:    logg.LevelInfo,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo())
 
        b.AssertLogMatches(`Dart Sass: foo`)
        b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:1:0: bar`)
@@ -334,12 +298,7 @@ T1: {{ $r.Content }}
        `
 
        c.Run("error in main", func(c *qt.C) {
-               b, err := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           c,
-                               TxtarString: strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1),
-                               NeedsOsFS:   true,
-                       }).BuildE()
+               b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1), hugolib.TestOptOsFs())
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `main.scss:8:13":`)
@@ -359,12 +318,7 @@ T1: {{ $r.Content }}
        })
 
        c.Run("error in import", func(c *qt.C) {
-               b, err := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           c,
-                               TxtarString: strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1),
-                               NeedsOsFS:   true,
-                       }).BuildE()
+               b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1), hugolib.TestOptOsFs())
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `_foo.scss:2:10":`)
@@ -412,12 +366,7 @@ b {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover;font-family:Hugo&#39;s New Roman}p{color:blue;font-size:24px}b{color:green}`)
 }
@@ -460,12 +409,7 @@ b {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover}p{color:blue;font-size:24px}b{color:green}`)
 }
@@ -516,13 +460,7 @@ float = 3.14
 T1: {{ $r.Content }}
                `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       LogLevel:    logg.LevelInfo,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo())
 
        b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:3:0: color`)
        b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:4:0: color`)
@@ -564,12 +502,7 @@ module github.com/gohugoio/tests/testHugoModules
 Styles: {{ $r.RelPermalink }}
                `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
 }
@@ -609,12 +542,7 @@ target = "assets/sass"
 .bar2 {color: blue;}
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       NeedsOsFS:   true,
-                       TxtarString: files,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
 }
index 3649791677e2e20979ed1cd561422c6b5c839da0..93cc05bf06458eabab523e49cc9424133a7b61b1 100644 (file)
@@ -49,12 +49,7 @@ moo {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           c,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(c, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: moo{color:#fff}`)
 }
@@ -92,12 +87,7 @@ T1: {{ $r.Content | safeHTML }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           c,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(c, files, hugolib.TestOptOsFs())
 
        // LibSass does not support regular CSS imports. There
        // is an open bug about it that probably will never be resolved.
@@ -169,12 +159,7 @@ zoo {
 @import "components/imports";
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           c,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(c, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: moo{color:#ccc}boo{color:green}zoo{color:pink}`)
 }
@@ -217,12 +202,7 @@ T1: {{ $r.Content }}
        `
 
        c.Run("error in main", func(c *qt.C) {
-               b, err := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           c,
-                               TxtarString: strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1),
-                               NeedsOsFS:   true,
-                       }).BuildE()
+               b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1), hugolib.TestOptOsFs())
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`themes/mytheme/assets/scss/main.scss:6:1": expected ':' after $maincolor in assignment statement`))
@@ -235,12 +215,7 @@ T1: {{ $r.Content }}
        })
 
        c.Run("error in import", func(c *qt.C) {
-               b, err := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           c,
-                               TxtarString: strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1),
-                               NeedsOsFS:   true,
-                       }).BuildE()
+               b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1), hugolib.TestOptOsFs())
 
                b.Assert(err, qt.IsNotNil)
                b.Assert(err.Error(), qt.Contains, `assets/scss/components/_foo.scss:2:1": expected ':' after $foocolor in assignment statement`)
@@ -287,12 +262,7 @@ b {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover;font-family:Hugo&#39;s New Roman}p{color:blue;font-size:var 24px}b{color:green}`)
 }
@@ -323,12 +293,7 @@ module github.com/gohugoio/tests/testHugoModules
 Styles: {{ $r.RelPermalink }}
                `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
 }
@@ -350,13 +315,7 @@ b {
 T1: {{ $r.Content }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       Running:     true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
 
        b.AssertFileContent("public/index.html", `color: red`)
 
@@ -407,14 +366,7 @@ h3 {
 {{ end }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       Running:     true,
-                       // LogLevel:    logg.LevelTrace,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
 
        b.AssertFileContent("public/index.html", `b.60a9f3bdc189ee8a857afd5b7e1b93ad1644de0873761a7c9bc84f781a821942.css`)
 
@@ -458,12 +410,7 @@ target = "assets/sass"
 .bar2 {color: blue;}
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       NeedsOsFS:   true,
-                       TxtarString: files,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
 }
index 8d0f13bb6be45f594f1edb1ce8c8573c917ea190..71216e3041bc637032d132b588b290c66ee6affa 100644 (file)
@@ -52,13 +52,7 @@ bmp: {{ $bmp.RelPermalink }}|}|{{ $bmp.Width }}|{{ $bmp.Height }}|{{ $bmp.MediaT
 anigif: {{ $anigif.RelPermalink }}|{{ $anigif.Width }}|{{ $anigif.Height }}|{{ $anigif.MediaType }}|
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       Running:     true,
-               }).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
 
        assertImages := func() {
                b.AssertFileContent("public/index.html", `
@@ -88,13 +82,7 @@ func TestSVGError(t *testing.T) {
 Width: {{ $svg.Width }}
 `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-                       Running:     true,
-               }).BuildE()
+       b, err := hugolib.TestE(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
 
        b.Assert(err, qt.IsNotNil)
        b.Assert(err.Error(), qt.Contains, `error calling Width: resource "/circle.svg" of media type "image/svg+xml" does not support this method: use reflect.IsImageResource, reflect.IsImageResourceProcessable, or reflect.IsImageResourceWithMeta to check if the resource supports this method before calling it`)
@@ -124,13 +112,9 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
 
        for range 3 {
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                               NeedsOsFS:   true,
-                               WorkingDir:  workingDir,
-                       }).Build()
+               b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+                       cfg.WorkingDir = workingDir
+               }))
 
                b.AssertFileCount("resources/_gen/images", 6)
                b.AssertFileCount("public/images", 1)
index 5f5ce10ddfb1c238d358639b560580d202f35e9f..88f62286fb9bfad28e956e640fc1e66d15767759 100644 (file)
@@ -74,12 +74,7 @@ Desc: {{ sort (sort $values "b" "desc") "a" "desc" }}
 
        for range 4 {
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := hugolib.Test(t, files)
 
                b.AssertFileContent("public/index.html", `
 Asc:  [map[a:0 b:0] map[a:0 b:0] map[a:0 b:3] map[a:1 b:0] map[a:1 b:1] map[a:1 b:2] map[a:1 b:2] map[a:2 b:0] map[a:2 b:0] map[a:2 b:0] map[a:2 b:1] map[a:2 b:2] map[a:3 b:0] map[a:3 b:0] map[a:3 b:0] map[a:3 b:0] map[a:3 b:1] map[a:3 b:1] map[a:3 b:1] map[a:3 b:3]]
@@ -144,12 +139,7 @@ func TestAppendNilsToSliceWithNils(t *testing.T) {
 
        for range 4 {
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               ).Build()
+               b := hugolib.Test(t, files)
 
                b.AssertFileContent("public/index.html", "[a &lt;nil&gt; c &lt;nil&gt;]")
 
index c03655add3ec7e9d504c8215b9502231135d10d5..342ca54882e13ce8ee1b846cf02fb7ae0fa66cd6 100644 (file)
@@ -16,7 +16,6 @@ package debug_test
 import (
        "testing"
 
-       "github.com/bep/logg"
        "github.com/gohugoio/hugo/hugolib"
 )
 
@@ -33,13 +32,7 @@ disableKinds = ["taxonomy", "term"]
 {{ end }}
 
 `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       LogLevel:    logg.LevelInfo,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptInfo())
 
        b.AssertLogContains("timer:  name foo count 5 duration")
 }
index cd9cadba3ad182333134bafcb41b5b2ffdcbcadf..209f9e0f8cc31bbeef714410cc89435dc1450a14 100644 (file)
@@ -37,13 +37,7 @@ START:|{{ range $entry := $entries }}{{ if not $entry.IsDir }}{{ $entry.Name }}|
 
   `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `
 START:|hugo.toml|myproject.txt|:END:
@@ -63,13 +57,7 @@ func TestReadFileNotExists(t *testing.T) {
 
   `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/index.html", `
 OK
index 399adb3749aa4056389f9d7e7cb57555ddce994f..8245b44f13497eadc0f1a263db695ea127dd7bcb 100644 (file)
@@ -26,7 +26,7 @@ import (
 func TestReadFile(t *testing.T) {
        t.Parallel()
 
-       b := newFileTestBuilder(t).Build()
+       b := newFileTestBuilder(t)
 
        // helpers.PrintFs(b.H.PathSpec.BaseFs.Work, "", _os.Stdout)
 
@@ -59,7 +59,7 @@ func TestFileExists(t *testing.T) {
        t.Parallel()
        c := qt.New(t)
 
-       b := newFileTestBuilder(t).Build()
+       b := newFileTestBuilder(t)
        ns := os.New(b.H.Deps)
 
        for _, test := range []struct {
@@ -86,7 +86,7 @@ func TestFileExists(t *testing.T) {
 
 func TestStat(t *testing.T) {
        t.Parallel()
-       b := newFileTestBuilder(t).Build()
+       b := newFileTestBuilder(t)
        ns := os.New(b.H.Deps)
 
        for _, test := range []struct {
@@ -118,11 +118,7 @@ f1-content
 f2-content
        `
 
-       return hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       WorkingDir:  "/mywork",
-               },
-       )
+       return hugolib.Test(t, files, hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+               c.WorkingDir = "/mywork"
+       }))
 }
index 6b5fc7ca47b6ea90ca18a0dee8b65f83703b0375..817033b40bcddd7c75e28a0159b5891a76987b02 100644 (file)
@@ -140,12 +140,7 @@ weight = 2
 
                        for range 1 {
 
-                               b := hugolib.NewIntegrationTestBuilder(
-                                       hugolib.IntegrationTestConfig{
-                                               T:           t,
-                                               TxtarString: files,
-                                       },
-                               ).Build()
+                               b := hugolib.Test(t, files)
 
                                b.AssertFileContent("public/index.html", `
 Heading OK.
index 04ea82bfd3f679563db1b95451abcf9c70014c1a..79a92f1e168cb084f03a95401e778ed682d7569b 100644 (file)
@@ -261,12 +261,7 @@ baseURL = 'http://example.com/'
 {{ partial "foo.html" . }}
   `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := hugolib.TestE(t, files)
 
        b.Assert(err, qt.Not(qt.IsNil))
        b.Assert(err.Error(), qt.Contains, "maximum template call stack size exceeded")
@@ -287,12 +282,7 @@ timeout = '200ms'
 {{ partialCached "foo.html" . }}
   `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := hugolib.TestE(t, files)
 
        b.Assert(err, qt.Not(qt.IsNil))
        b.Assert(err.Error(), qt.Contains, `error calling partialCached: circular call stack detected in partial`)
index 60889cb077b8f0ec49c3eca5bb0eafd7b7cc5029..faca7af3ac81e1a7bfc9803b46632be8bc5dcba9 100644 (file)
@@ -85,11 +85,7 @@ func TestCopyPageShouldFail(t *testing.T) {
 
        `
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               }).BuildE()
+       b, err := hugolib.TestE(t, files)
 
        b.Assert(err, qt.IsNotNil)
 }
index 87656b38c9e22226abc76f5bbb7a58e5d2a0dce9..9bb17b4650f0199eb953be309c4a51d80cf14a56 100644 (file)
@@ -29,9 +29,7 @@ import (
 func TestTimeLocation(t *testing.T) {
        t.Parallel()
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        loc, _ := gtime.LoadLocation("America/Antigua")
        ns := time.New(htime.NewTimeFormatter(golocales.New("en")), loc, b.H.Deps)
@@ -91,9 +89,7 @@ func TestTimeLocation(t *testing.T) {
 func TestFormat(t *testing.T) {
        c := qt.New(t)
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        c.Run("UTC", func(c *qt.C) {
                c.Parallel()
@@ -153,9 +149,7 @@ func TestFormat(t *testing.T) {
 func TestDuration(t *testing.T) {
        t.Parallel()
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, b.H.Deps)
 
@@ -200,9 +194,7 @@ func TestDuration(t *testing.T) {
 func TestIn(t *testing.T) {
        t.Parallel()
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, b.H.Deps)
 
@@ -241,9 +233,7 @@ func TestIn(t *testing.T) {
 var timeZoneNames []string = []string{"America/New_York", "Europe/Oslo", "Australia/Sydney", "UTC", "Local"}
 
 func BenchmarkInWithCaching(b *testing.B) {
-       bb := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: b},
-       ).Build()
+       bb := hugolib.Test(b, "")
 
        ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, bb.H.Deps)
 
index d71c3e445b183cd36f9fcedf74aa63be3283a25b..12ffacc9522650a8203d795e7c265da29d62b0a7 100644 (file)
@@ -46,13 +46,7 @@ title: "**BatMan**"
 ---
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        d := b.H.Sites[0].Deps
 
@@ -78,13 +72,7 @@ title: "**BatMan**"
        }
 
        files += fmt.Sprintf("-- layouts/single.html --\n%s\n", strings.Join(templates, "\n"))
-       b = hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       ).Build()
+       b = hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/blog/hugo-rocks/index.html", expected...)
 }
index 6ba9cbbc472a0c33abb516fcbdc7ebc4ec8bb6d2..e8229a0d52b53ea69408665728aa6b7121c566ca 100644 (file)
@@ -379,14 +379,7 @@ title: "P1"
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/p1/index.html", "MAIN /_default/single.html")
 
index 420988f4f23a8b08a0c4e8de2408c4bed13db286..f232b0fea70ef9cad7052192275000a5a19cf65d 100644 (file)
@@ -55,14 +55,7 @@ counter2: {{ .Scratch.Get "counter" }}
 
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-                       NeedsOsFS:   true,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files, hugolib.TestOptOsFs())
 
        b.AssertFileContent("public/p1/index.html", `
 continue:1345:END:
@@ -124,13 +117,7 @@ title: "S3P1"
 {{ define "main" }}{{ .Title }}{{ end }}
        `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-       b.Build()
+       b := hugolib.Test(t, files)
 
        b.AssertFileContent("public/s1/p1/index.html", `S1P1`)
        b.AssertFileContent("public/s2/p1/index.html", `S2P1`)
@@ -152,13 +139,7 @@ func TestGoTemplateBugs(t *testing.T) {
 {{ end }}
        `
 
-               b := hugolib.NewIntegrationTestBuilder(
-                       hugolib.IntegrationTestConfig{
-                               T:           t,
-                               TxtarString: files,
-                       },
-               )
-               b.Build()
+               b := hugolib.Test(t, files)
 
                b.AssertFileContent("public/index.html", `key = value`)
        })
@@ -176,12 +157,7 @@ var a = §§{{.Title }}§§;
 
        files := strings.ReplaceAll(filesTemplate, "SECURITYCONFIG", "")
 
-       b, err := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       ).BuildE()
+       b, err := hugolib.TestE(t, files)
 
        // This used to fail, but not in >= Hugo 0.121.0.
        b.Assert(err, qt.IsNil)
index bbd7acf66ec6d3b659f5a44182ef8c5ca394835b..26ea28bc3a6810dac9985ea0cdbd7973d6eea5b1 100644 (file)
@@ -26,9 +26,7 @@ import (
 func TestRemarshal(t *testing.T) {
        t.Parallel()
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
        c := qt.New(t)
@@ -241,9 +239,7 @@ c: &c [*b, *b, *b, *b, *b, *b, *b, *b, *b, *b]
 
 `
 
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
index 6347452cf203b70818e14767f8e128fc6c7b61dc..9e7f7006b89c1bd375c62c4fbe1887f8a3b9d327 100644 (file)
@@ -99,14 +99,7 @@ disableKinds = ['page','rss','section','sitemap','taxonomy','term']
 -- layouts/home.html --
 {{ highlight "a" "b" 0 }}
   `
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{
-                       T:           t,
-                       TxtarString: files,
-               },
-       )
-
-       _, err := b.BuildE()
+       b, err := hugolib.TestE(t, files)
        b.Assert(err.Error(), qt.Contains, "error calling highlight: invalid Highlight option: 0")
 }
 
index 1f6c99ec4f7966a9a9f73a29fcfa13d1f95630ba..a74f9d5b53bfcb26cc4f4d9f63773125da9b5aff 100644 (file)
@@ -29,9 +29,7 @@ type tstNoStringer struct{}
 
 func TestEmojify(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -59,9 +57,7 @@ func TestEmojify(t *testing.T) {
 
 func TestHighlight(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -104,9 +100,7 @@ func TestCanHighlight(t *testing.T) {
 
 func TestHTMLEscape(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -134,9 +128,7 @@ func TestHTMLEscape(t *testing.T) {
 
 func TestHTMLUnescape(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -164,9 +156,7 @@ func TestHTMLUnescape(t *testing.T) {
 
 func TestMarkdownify(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -194,9 +184,7 @@ func TestMarkdownify(t *testing.T) {
 // Issue #3040
 func TestMarkdownifyBlocksOfText(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -220,9 +208,7 @@ And then some.
 
 func TestPlainify(t *testing.T) {
        t.Parallel()
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
index 3d60dcda71308346c2b6c90c5c977ff0927353ed..c2b177bd2863f7aa4542d841c3013bcd2782e548 100644 (file)
@@ -82,9 +82,7 @@ func (t testContentResource) Key() string {
 }
 
 func TestUnmarshal(t *testing.T) {
-       b := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: t},
-       ).Build()
+       b := hugolib.Test(t, "")
 
        ns := transform.New(b.H.Deps)
 
@@ -191,9 +189,7 @@ a;b;c`, mime: media.Builtin.CSVType}, map[string]any{"DElimiter": ";", "Comment"
 }
 
 func BenchmarkUnmarshalString(b *testing.B) {
-       bb := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: b},
-       ).Build()
+       bb := hugolib.Test(b, "")
 
        ns := transform.New(bb.H.Deps)
 
@@ -218,9 +214,7 @@ func BenchmarkUnmarshalString(b *testing.B) {
 }
 
 func BenchmarkUnmarshalResource(b *testing.B) {
-       bb := hugolib.NewIntegrationTestBuilder(
-               hugolib.IntegrationTestConfig{T: b},
-       ).Build()
+       bb := hugolib.Test(b, "")
 
        ns := transform.New(bb.H.Deps)