diff options
author | Bjørn Erik Pedersen <[email protected]> | 2020-01-22 11:57:23 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-01-23 11:50:02 +0100 |
commit | 17af79a03e249a731cf5634ffea23ca00774333d (patch) | |
tree | 66596a159aa57c948f1ffe272e5cd8ab86c7c1bf /hugolib/content_render_hooks_test.go | |
parent | 2fefc01606fddb119f368c89fb2dedd452ad6547 (diff) | |
download | hugo-17af79a03e249a731cf5634ffea23ca00774333d.tar.gz hugo-17af79a03e249a731cf5634ffea23ca00774333d.zip |
Fix 0.62.1 server rebuild slowdown regression
Fixes #6784
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r-- | hugolib/content_render_hooks_test.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go index 8aba1dd8c..5290ebcbd 100644 --- a/hugolib/content_render_hooks_test.go +++ b/hugolib/content_render_hooks_test.go @@ -14,7 +14,10 @@ package hugolib import ( + "fmt" "testing" + + qt "github.com/frankban/quicktest" ) func TestRenderHooks(t *testing.T) { @@ -118,7 +121,20 @@ title: With RenderString {{< myshortcode5 >}}Inner Link: [Inner Link](https://www.gohugo.io "Hugo's Homepage"){{< /myshortcode5 >}} `) - b.Build(BuildCfg{}) + + for i := 1; i <= 30; i++ { + // Add some content with no shortcodes or links, i.e no templates needed. + b.WithContent(fmt.Sprintf("blog/notempl%d.md", i), `--- +title: No Template +--- + +## Content +`) + } + counters := &testCounters{} + b.Build(BuildCfg{testCounters: counters}) + b.Assert(int(counters.contentRenderCounter), qt.Equals, 50) + b.AssertFileContent("public/blog/p1/index.html", ` <p>Cool Page|https://www.google.com|Title: Google's Homepage|Text: First Link|END</p> Text: Second @@ -149,7 +165,11 @@ SHORT3| "layouts/shortcodes/myshortcode3.html", `SHORT3_EDITED|`, ) - b.Build(BuildCfg{}) + counters = &testCounters{} + b.Build(BuildCfg{testCounters: counters}) + // Make sure that only content using the changed templates are re-rendered. + b.Assert(int(counters.contentRenderCounter), qt.Equals, 7) + b.AssertFileContent("public/customview/p1/index.html", `.Render: myrender: Custom View|P4: PARTIAL4_EDITED`) b.AssertFileContent("public/blog/p1/index.html", `<p>EDITED: https://www.google.com|</p>`, "SHORT3_EDITED|") b.AssertFileContent("public/blog/p2/index.html", `PARTIAL1_EDITED`) |