aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/integrationtest_builder.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-04-16 09:32:08 +0200
committerBjørn Erik Pedersen <[email protected]>2024-04-16 12:06:37 +0200
commitfa60a2fbc317aa3b1fcfcaf2e842bdb439b8e7f1 (patch)
tree901e4f0d595f5e22908af979f1b2894a0aea95eb /hugolib/integrationtest_builder.go
parentfe63de3a83da351fa9b31498486a2f6538a70bde (diff)
downloadhugo-fa60a2fbc317aa3b1fcfcaf2e842bdb439b8e7f1.tar.gz
hugo-fa60a2fbc317aa3b1fcfcaf2e842bdb439b8e7f1.zip
Fix server rebuilds when adding a content file on Linux
Fixes #12362
Diffstat (limited to 'hugolib/integrationtest_builder.go')
-rw-r--r--hugolib/integrationtest_builder.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index be11c18d6..8daf7b1ca 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"regexp"
+ "runtime"
"sort"
"strings"
"sync"
@@ -685,8 +686,17 @@ func (s *IntegrationTestBuilder) build(cfg BuildCfg) error {
return nil
}
+// We simulate the fsnotify events.
+// See the test output in https://github.com/bep/fsnotifyeventlister for what events gets produced
+// by the different OSes.
func (s *IntegrationTestBuilder) changeEvents() []fsnotify.Event {
- var events []fsnotify.Event
+ var (
+ events []fsnotify.Event
+ isLinux = runtime.GOOS == "linux"
+ isMacOs = runtime.GOOS == "darwin"
+ isWindows = runtime.GOOS == "windows"
+ )
+
for _, v := range s.removedFiles {
events = append(events, fsnotify.Event{
Name: v,
@@ -713,12 +723,32 @@ func (s *IntegrationTestBuilder) changeEvents() []fsnotify.Event {
Name: v,
Op: fsnotify.Write,
})
+ if isLinux || isWindows {
+ // Duplicate write events, for some reason.
+ events = append(events, fsnotify.Event{
+ Name: v,
+ Op: fsnotify.Write,
+ })
+ }
+ if isMacOs {
+ events = append(events, fsnotify.Event{
+ Name: v,
+ Op: fsnotify.Chmod,
+ })
+ }
}
for _, v := range s.createdFiles {
events = append(events, fsnotify.Event{
Name: v,
Op: fsnotify.Create,
})
+ if isLinux || isWindows {
+ events = append(events, fsnotify.Event{
+ Name: v,
+ Op: fsnotify.Write,
+ })
+ }
+
}
// Shuffle events.