aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/cascade_test.go66
-rw-r--r--hugolib/integrationtest_builder.go29
-rw-r--r--hugolib/site_new.go4
3 files changed, 84 insertions, 15 deletions
diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go
index bb328f761..b9b80a3a1 100644
--- a/hugolib/cascade_test.go
+++ b/hugolib/cascade_test.go
@@ -674,6 +674,8 @@ S1|p1:|p2:p2|
// Issue 11977.
func TestCascadeExtensionInPath(t *testing.T) {
+ t.Parallel()
+
files := `
-- hugo.toml --
baseURL = "https://example.org"
@@ -700,3 +702,67 @@ title: "Post 1"
b.Assert(err, qt.IsNotNil)
b.AssertLogContains(`cascade target path "/posts/post-1.de.md" looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/`)
}
+
+func TestCascadeExtensionInPathIgnore(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+ignoreLogs = ['cascade-pattern-with-extension']
+[languages]
+[languages.en]
+weight = 1
+[languages.de]
+-- content/_index.de.md --
++++
+[[cascade]]
+[cascade.params]
+foo = 'bar'
+[cascade._target]
+path = '/posts/post-1.de.md'
++++
+-- content/posts/post-1.de.md --
+---
+title: "Post 1"
+---
+-- layouts/_default/single.html --
+{{ .Title }}|{{ .Params.foo }}$
+`
+ b := Test(t, files)
+ b.AssertLogNotContains(`looks like a path with an extension`)
+}
+
+func TestCascadConfigExtensionInPath(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+[[cascade]]
+[cascade.params]
+foo = 'bar'
+[cascade._target]
+path = '/p1.md'
+`
+ b, err := TestE(t, files)
+ b.Assert(err, qt.IsNotNil)
+ b.AssertLogContains(`looks like a path with an extension`)
+}
+
+func TestCascadConfigExtensionInPathIgnore(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+ignoreLogs = ['cascade-pattern-with-extension']
+[[cascade]]
+[cascade.params]
+foo = 'bar'
+[cascade._target]
+path = '/p1.md'
+`
+ b := Test(t, files)
+ b.AssertLogNotContains(`looks like a path with an extension`)
+}
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
}
diff --git a/hugolib/site_new.go b/hugolib/site_new.go
index 2e8933497..3bcc307ad 100644
--- a/hugolib/site_new.go
+++ b/hugolib/site_new.go
@@ -127,6 +127,7 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
SuppressStatements: conf.IgnoredLogs(),
}
logger = loggers.New(logOpts)
+
}
memCache := dynacache.New(dynacache.Options{Running: conf.Running(), Log: logger})
@@ -145,6 +146,9 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
}
confm := cfg.Configs
+ if err := confm.Validate(logger); err != nil {
+ return nil, err
+ }
var sites []*Site
ns := &contentNodeShifter{