diff options
Diffstat (limited to 'hugolib/hugo_sites_build_errors_test.go')
-rw-r--r-- | hugolib/hugo_sites_build_errors_test.go | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/hugolib/hugo_sites_build_errors_test.go b/hugolib/hugo_sites_build_errors_test.go index e29fd060e..5a8b9f76f 100644 --- a/hugolib/hugo_sites_build_errors_test.go +++ b/hugolib/hugo_sites_build_errors_test.go @@ -7,8 +7,6 @@ import ( "strings" "testing" - "github.com/gohugoio/hugo/htesting" - qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/herrors" ) @@ -57,7 +55,6 @@ func TestSiteBuildErrors(t *testing.T) { assertCreateError func(a testSiteBuildErrorAsserter, err error) assertBuildError func(a testSiteBuildErrorAsserter, err error) }{ - { name: "Base template parse failed", fileType: base, @@ -139,7 +136,6 @@ func TestSiteBuildErrors(t *testing.T) { // Make sure that it contains both the content file and template a.assertErrorMessage(`"content/myyaml.md:7:10": failed to render shortcode "sc": failed to process shortcode: "layouts/shortcodes/sc.html:4:22": execute of template failed: template: shortcodes/sc.html:4:22: executing "shortcodes/sc.html" at <.Page.Titles>: can't evaluate field Titles in type page.Page`, fe.Error()) a.c.Assert(fe.Position().LineNumber, qt.Equals, 7) - }, }, { @@ -312,7 +308,6 @@ Some content. } }) } - } // Issue 9852 @@ -345,7 +340,6 @@ minify = true b.Assert(fe.Error(), qt.Contains, "unexpected = in expression on line 2 and column 9") b.Assert(filepath.ToSlash(fe.Position().Filename), qt.Contains, "hugo-transform-error") b.Assert(os.Remove(fe.Position().Filename), qt.IsNil) - } func TestErrorNestedRender(t *testing.T) { @@ -394,7 +388,6 @@ line 4 b.Assert(errors[3].Position().LineNumber, qt.Equals, 3) b.Assert(errors[3].Position().ColumnNumber, qt.Equals, 6) b.Assert(errors[3].ErrorContext().Lines, qt.DeepEquals, []string{"line 1", "line 2", "123{{ .ThisDoesNotExist }}", "line 4"}) - } func TestErrorNestedShortcode(t *testing.T) { @@ -437,16 +430,15 @@ line 4 b.Assert(err, qt.IsNotNil) errors := herrors.UnwrapFileErrorsWithErrorContext(err) - b.Assert(errors, qt.HasLen, 3) - - b.Assert(errors[0].Position().LineNumber, qt.Equals, 6) - b.Assert(errors[0].Position().ColumnNumber, qt.Equals, 1) - b.Assert(errors[0].ErrorContext().ChromaLexer, qt.Equals, "md") - b.Assert(errors[0].Error(), qt.Contains, filepath.FromSlash(`"/content/_index.md:6:1": failed to render shortcode "hello": failed to process shortcode: "/layouts/shortcodes/hello.html:2:5":`)) - b.Assert(errors[0].ErrorContext().Lines, qt.DeepEquals, []string{"", "## Hello", "{{< hello >}}", ""}) - b.Assert(errors[1].ErrorContext().Lines, qt.DeepEquals, []string{"line 1", "12{{ partial \"foo.html\" . }}", "line 4", "line 5"}) - b.Assert(errors[2].ErrorContext().Lines, qt.DeepEquals, []string{"line 1", "line 2", "123{{ .ThisDoesNotExist }}", "line 4"}) + b.Assert(errors, qt.HasLen, 4) + b.Assert(errors[1].Position().LineNumber, qt.Equals, 6) + b.Assert(errors[1].Position().ColumnNumber, qt.Equals, 1) + b.Assert(errors[1].ErrorContext().ChromaLexer, qt.Equals, "md") + b.Assert(errors[1].Error(), qt.Contains, filepath.FromSlash(`"/content/_index.md:6:1": failed to render shortcode "hello": failed to process shortcode: "/layouts/shortcodes/hello.html:2:5":`)) + b.Assert(errors[1].ErrorContext().Lines, qt.DeepEquals, []string{"", "## Hello", "{{< hello >}}", ""}) + b.Assert(errors[2].ErrorContext().Lines, qt.DeepEquals, []string{"line 1", "12{{ partial \"foo.html\" . }}", "line 4", "line 5"}) + b.Assert(errors[3].ErrorContext().Lines, qt.DeepEquals, []string{"line 1", "line 2", "123{{ .ThisDoesNotExist }}", "line 4"}) } func TestErrorRenderHookHeading(t *testing.T) { @@ -483,9 +475,8 @@ line 5 b.Assert(err, qt.IsNotNil) errors := herrors.UnwrapFileErrorsWithErrorContext(err) - b.Assert(errors, qt.HasLen, 2) + b.Assert(errors, qt.HasLen, 3) b.Assert(errors[0].Error(), qt.Contains, filepath.FromSlash(`"/content/_index.md:1:1": "/layouts/_default/_markup/render-heading.html:2:5": execute of template failed`)) - } func TestErrorRenderHookCodeblock(t *testing.T) { @@ -527,10 +518,9 @@ line 5 b.Assert(err, qt.IsNotNil) errors := herrors.UnwrapFileErrorsWithErrorContext(err) - b.Assert(errors, qt.HasLen, 2) + b.Assert(errors, qt.HasLen, 3) first := errors[0] b.Assert(first.Error(), qt.Contains, filepath.FromSlash(`"/content/_index.md:7:1": "/layouts/_default/_markup/render-codeblock-foo.html:2:5": execute of template failed`)) - } func TestErrorInBaseTemplate(t *testing.T) { @@ -580,7 +570,6 @@ toc line 4 b.Assert(err, qt.IsNotNil) b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`render of "home" failed: "/layouts/baseof.html:4:6"`)) - }) t.Run("index template", func(t *testing.T) { @@ -595,7 +584,6 @@ toc line 4 b.Assert(err, qt.IsNotNil) b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`render of "home" failed: "/layouts/index.html:3:7"`)) - }) t.Run("partial from define", func(t *testing.T) { @@ -611,17 +599,11 @@ toc line 4 b.Assert(err, qt.IsNotNil) b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`render of "home" failed: "/layouts/index.html:7:8": execute of template failed`)) b.Assert(err.Error(), qt.Contains, `execute of template failed: template: partials/toc.html:2:8: executing "partials/toc.html"`) - }) - } // https://github.com/gohugoio/hugo/issues/5375 func TestSiteBuildTimeout(t *testing.T) { - if !htesting.IsCI() { - //defer leaktest.CheckTimeout(t, 10*time.Second)() - } - b := newTestSitesBuilder(t) b.WithConfigFile("toml", ` timeout = 5 |