Skip to content

Commit

Permalink
Add a writeStats stresstest
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Apr 21, 2020
1 parent b3c8257 commit f6ad32b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions hugolib/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
package hugolib

import (
"encoding/json"
"fmt"
"path/filepath"
"strings"
"testing"

"github.com/gohugoio/hugo/publisher"

"github.com/spf13/viper"

"github.com/markbates/inflect"
Expand Down Expand Up @@ -1024,3 +1027,55 @@ Some text.
}
`)
}

func TestClassCollectorStress(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithConfigFile("toml", `
disableKinds = ["home", "section", "taxonomy", "taxonomyTerm" ]
[languages]
[languages.en]
[languages.nb]
[languages.no]
[languages.sv]
[build]
writeStats = true
`)

b.WithTemplates("_default/single.html", `
<div class="c d e" id="el2">Foo</div>
Some text.
<div class="{{ .Title }}">
ABC.
</div>
<div class="f"></div>
`)

for _, lang := range []string{"en", "nb", "no", "sv"} {

for i := 100; i <= 999; i++ {
b.WithContent(fmt.Sprintf("p%d.%s.md", i, lang), fmt.Sprintf("---\ntitle: p%s%d\n---", lang, i))
}
}

b.Build(BuildCfg{})

content := b.FileContent("hugo_stats.json")

stats := &publisher.PublishStats{}
b.Assert(json.Unmarshal([]byte(content), stats), qt.IsNil)

els := stats.HTMLElements

b.Assert(els.Classes, qt.HasLen, 3604) // (4 * 900) + 4
b.Assert(els.Tags, qt.HasLen, 5)
b.Assert(els.IDs, qt.HasLen, 1)

}

0 comments on commit f6ad32b

Please sign in to comment.