parser/pageparser: Add a parser fuzz test

Ran it for 40 minutes on my MacBook Pro, and it found no issues.
This commit is contained in:
Bjørn Erik Pedersen
2026-04-07 21:44:38 +02:00
parent d6bc8165e6
commit 8f94d65cac
+27
View File
@@ -22,6 +22,33 @@ import (
"github.com/gohugoio/hugo/parser/metadecoders"
)
func FuzzParse(f *testing.F) {
samples := []string{
`{{< foo >}}`,
`{{% foo %}}`,
`{{< foo >}} {{< bar >}}`,
`---
title: "Front Matters"
---
This is some summary. This is some summary. This is some summary. This is some summary.
<!--more-->
Foo bars.
`,
}
for _, s := range samples {
f.Add([]byte(s))
}
f.Fuzz(func(t *testing.T, b []byte) {
cfg := Config{}
_, _ = parseBytes(b, cfg, lexIntroSection)
})
}
func BenchmarkParse(b *testing.B) {
start := `