diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-01-30 09:23:21 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-01-30 20:12:03 +0100 |
commit | 4e84f57efb57f5c8a850e4c1d562a0bcc7bd1700 (patch) | |
tree | 678ed4f283b67339c341ad355306ca0d5d771ad8 /hugolib | |
parent | f31a6db797c9251a362ef9f8ad4c03fb608b5ac0 (diff) | |
download | hugo-4e84f57efb57f5c8a850e4c1d562a0bcc7bd1700.tar.gz hugo-4e84f57efb57f5c8a850e4c1d562a0bcc7bd1700.zip |
Add warnidf template function
Also rename config `ignoreErrors` => `ignoreLogs`
But the old still works.
Closes #9189
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/integrationtest_builder.go | 20 | ||||
-rw-r--r-- | hugolib/site_new.go | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go index a46ae7275..222c8ec2d 100644 --- a/hugolib/integrationtest_builder.go +++ b/hugolib/integrationtest_builder.go @@ -57,6 +57,13 @@ func TestOptDebug() TestOpt { } } +// TestOptWarn will enable warn logging in integration tests. +func TestOptWarn() TestOpt { + return func(c *IntegrationTestConfig) { + c.LogLevel = logg.LevelWarn + } +} + // TestOptWithNFDOnDarwin will normalize the Unicode filenames to NFD on Darwin. func TestOptWithNFDOnDarwin() TestOpt { return func(c *IntegrationTestConfig) { @@ -181,9 +188,18 @@ func (b *lockingBuffer) Write(p []byte) (n int, err error) { return } -func (s *IntegrationTestBuilder) AssertLogContains(text string) { +func (s *IntegrationTestBuilder) AssertLogContains(els ...string) { s.Helper() - s.Assert(s.logBuff.String(), qt.Contains, text) + for _, el := range els { + s.Assert(s.logBuff.String(), 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) + } } func (s *IntegrationTestBuilder) AssertLogMatches(expression string) { diff --git a/hugolib/site_new.go b/hugolib/site_new.go index 0cab71352..debb81e77 100644 --- a/hugolib/site_new.go +++ b/hugolib/site_new.go @@ -124,7 +124,7 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) { Stdout: cfg.LogOut, Stderr: cfg.LogOut, StoreErrors: conf.Running(), - SuppressStatements: conf.IgnoredErrors(), + SuppressStatements: conf.IgnoredLogs(), } logger = loggers.New(logOpts) } |