diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-02-26 16:13:05 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-02-26 17:29:37 +0100 |
commit | 1736ef745908454fb45b9e566aa8d44722990c05 (patch) | |
tree | 2bf7eff7ed77dcab3cdd6d52990cdc877d00ac3f /hugolib/integrationtest_builder.go | |
parent | d4be1643a08cbaaf577d3b6df6549405b865c3f3 (diff) | |
download | hugo-1736ef745908454fb45b9e566aa8d44722990c05.tar.gz hugo-1736ef745908454fb45b9e566aa8d44722990c05.zip |
Fix cascade-pattern-with-extension for cascade in site config
Also clean up the log handling in the integration tester, most notably lost logs during the config loading.
Fixes #12151
Diffstat (limited to 'hugolib/integrationtest_builder.go')
-rw-r--r-- | hugolib/integrationtest_builder.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go index 8c7017a87..acbc093ba 100644 --- a/hugolib/integrationtest_builder.go +++ b/hugolib/integrationtest_builder.go @@ -169,10 +169,11 @@ type IntegrationTestBuilder struct { renamedFiles []string renamedDirs []string - buildCount int - GCCount int - counters *buildCounters - logBuff lockingBuffer + buildCount int + GCCount int + counters *buildCounters + logBuff lockingBuffer + lastBuildLog string builderInit sync.Once } @@ -192,21 +193,21 @@ func (b *lockingBuffer) Write(p []byte) (n int, err error) { func (s *IntegrationTestBuilder) AssertLogContains(els ...string) { s.Helper() for _, el := range els { - s.Assert(s.logBuff.String(), qt.Contains, el) + s.Assert(s.lastBuildLog, qt.Contains, el) } } func (s *IntegrationTestBuilder) AssertLogNotContains(els ...string) { s.Helper() for _, el := range els { - s.Assert(s.logBuff.String(), qt.Not(qt.Contains), el) + s.Assert(s.lastBuildLog, qt.Not(qt.Contains), el) } } func (s *IntegrationTestBuilder) AssertLogMatches(expression string) { s.Helper() re := regexp.MustCompile(expression) - s.Assert(re.MatchString(s.logBuff.String()), qt.IsTrue, qt.Commentf(s.logBuff.String())) + s.Assert(re.MatchString(s.lastBuildLog), qt.IsTrue, qt.Commentf(s.lastBuildLog)) } func (s *IntegrationTestBuilder) AssertBuildCountData(count int) { @@ -341,7 +342,7 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder { s.Helper() _, err := s.BuildE() if s.Cfg.Verbose || err != nil { - fmt.Println(s.logBuff.String()) + fmt.Println(s.lastBuildLog) if s.H != nil && err == nil { for _, s := range s.H.Sites { m := s.pageMap @@ -352,7 +353,7 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder { } } } else if s.Cfg.LogLevel <= logg.LevelDebug { - fmt.Println(s.logBuff.String()) + fmt.Println(s.lastBuildLog) } s.Assert(err, qt.IsNil) if s.Cfg.RunGC { @@ -364,7 +365,7 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder { } func (s *IntegrationTestBuilder) LogString() string { - return s.logBuff.String() + return s.lastBuildLog } func (s *IntegrationTestBuilder) BuildE() (*IntegrationTestBuilder, error) { @@ -381,6 +382,7 @@ func (s *IntegrationTestBuilder) Init() *IntegrationTestBuilder { if err := s.initBuilder(); err != nil { s.Fatalf("Failed to init builder: %s", err) } + s.lastBuildLog = s.logBuff.String() return s } @@ -626,10 +628,11 @@ func (s *IntegrationTestBuilder) build(cfg BuildCfg) error { s.Helper() defer func() { s.reset() + s.lastBuildLog = s.logBuff.String() + s.logBuff.Reset() }() changeEvents := s.changeEvents() - s.logBuff.Reset() s.counters = &buildCounters{} cfg.testCounters = s.counters @@ -643,10 +646,6 @@ func (s *IntegrationTestBuilder) build(cfg BuildCfg) error { if err != nil { return err } - logErrorCount := s.H.NumLogErrors() - if logErrorCount > 0 { - return fmt.Errorf("logged %d error(s): %s", logErrorCount, s.logBuff.String()) - } return nil } |