]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Extract the baseline benchmark to a test
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 26 Jun 2022 07:56:01 +0000 (09:56 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 26 Jun 2022 07:56:01 +0000 (09:56 +0200)
hugolib/hugo_smoke_test.go

index 241ac537de2d4609a50b095a4156adce93da5f6a..0c14414e5ab05b9984331bf9d6ea5493ba82911d 100644 (file)
@@ -322,7 +322,36 @@ The content.
        b.CreateSites().Build(BuildCfg{})
 }
 
+// This is just a test to verify that BenchmarkBaseline is working as intended.
+func TestBenchmarkBaseline(t *testing.T) {
+       cfg := IntegrationTestConfig{
+               T:           t,
+               TxtarString: benchmarkBaselineFiles(),
+       }
+       b := NewIntegrationTestBuilder(cfg).Build()
+
+       b.Assert(len(b.H.Sites), qt.Equals, 4)
+
+}
+
 func BenchmarkBaseline(b *testing.B) {
+       cfg := IntegrationTestConfig{
+               T:           b,
+               TxtarString: benchmarkBaselineFiles(),
+       }
+       builders := make([]*IntegrationTestBuilder, b.N)
+
+       for i := range builders {
+               builders[i] = NewIntegrationTestBuilder(cfg)
+       }
+
+       b.ResetTimer()
+       for i := 0; i < b.N; i++ {
+               builders[i].Build()
+       }
+}
+
+func benchmarkBaselineFiles() string {
        files := `
 -- config.toml --
 baseURL = "https://example.com"
@@ -410,18 +439,5 @@ Aliqua labore enim et sint anim amet excepteur ea dolore.
                }
        }
 
-       cfg := IntegrationTestConfig{
-               T:           b,
-               TxtarString: files,
-       }
-       builders := make([]*IntegrationTestBuilder, b.N)
-
-       for i := range builders {
-               builders[i] = NewIntegrationTestBuilder(cfg)
-       }
-
-       b.ResetTimer()
-       for i := 0; i < b.N; i++ {
-               builders[i].Build()
-       }
+       return files
 }