summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-21 20:16:02 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-22 15:36:27 +0100
commit16406d9d77cb4861bba9df8ca39e7dadfe41eb45 (patch)
treef32a3921081e40a748613bd87eba7940d6b975db /hugolib
parente75784930dca9e367019ce498fd15076a63edb34 (diff)
Fix regression on handling of overlapping file mounts
But note that the overlay file system is set up horizontally (project -> module1 -> module2), so I would not recommend too complex overlapping mount setups within the same module. But this worked in v0.122.0, so we should fix it. Fixes #12103
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/filesystems/basefs_test.go42
-rw-r--r--hugolib/integrationtest_builder.go6
2 files changed, 44 insertions, 4 deletions
diff --git a/hugolib/filesystems/basefs_test.go b/hugolib/filesystems/basefs_test.go
index ebbb378d3..f5b7b6170 100644
--- a/hugolib/filesystems/basefs_test.go
+++ b/hugolib/filesystems/basefs_test.go
@@ -478,11 +478,47 @@ Home.
_ = stat("blog/b1.md")
}
+func TestStaticComposite(t *testing.T) {
+ files := `
+-- hugo.toml --
+disableKinds = ["taxonomy", "term"]
+[module]
+[[module.mounts]]
+source = "myfiles/f1.txt"
+target = "static/files/f1.txt"
+[[module.mounts]]
+source = "f3.txt"
+target = "static/f3.txt"
+[[module.mounts]]
+source = "static"
+target = "static"
+-- static/files/f2.txt --
+f2
+-- myfiles/f1.txt --
+f1
+-- f3.txt --
+f3
+-- layouts/home.html --
+Home.
+
+`
+ b := hugolib.Test(t, files)
+
+ b.AssertFs(b.H.BaseFs.StaticFs(""), `
+. true
+f3.txt false
+files true
+files/f1.txt false
+files/f2.txt false
+`)
+}
+
func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) {
c.Helper()
- count, _, err := countFilesAndGetFilenames(fs, dirname)
- c.Assert(err, qt.IsNil)
- c.Assert(count, qt.Equals, expected)
+ count, names, err := countFilesAndGetFilenames(fs, dirname)
+ namesComment := qt.Commentf("filenames: %v", names)
+ c.Assert(err, qt.IsNil, namesComment)
+ c.Assert(count, qt.Equals, expected, namesComment)
}
func checkFileContent(fs afero.Fs, filename string, c *qt.C, expected ...string) {
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index 194b79c68..8c7017a87 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -275,9 +275,13 @@ func (s *IntegrationTestBuilder) AssertFileContentExact(filename string, matches
}
func (s *IntegrationTestBuilder) AssertPublishDir(matches ...string) {
+ s.AssertFs(s.fs.PublishDir, matches...)
+}
+
+func (s *IntegrationTestBuilder) AssertFs(fs afero.Fs, matches ...string) {
s.Helper()
var buff bytes.Buffer
- helpers.PrintFs(s.H.Fs.PublishDir, "", &buff)
+ helpers.PrintFs(fs, "", &buff)
printFsLines := strings.Split(buff.String(), "\n")
sort.Strings(printFsLines)
content := strings.TrimSpace((strings.Join(printFsLines, "\n")))