summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-04 11:09:03 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-04 13:40:55 +0100
commitec1c97e7e9d62ce5245135e0906fdedf14af0cae (patch)
tree9dedccab1c6039f9cfc74de6c2df727f3ca488c1 /hugolib
parentf10009e7f10a0b5f60fe93709b79aa966d6ad02f (diff)
Work around --gc failure on Windows <= 10
This applies two related fixes/improvements: * The --gc now keeps empty `_resources/_gen/images` etc folders, even if empty. This should have been the behaviour from the start. * Also, if removal of an empty dir on Windows fails with the "used by another process" error, just ignore it for now. Fixes #10781
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/integrationtest_builder.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index f0e3c504d..8bd458bc1 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -84,6 +84,7 @@ type IntegrationTestBuilder struct {
renamedFiles []string
buildCount int
+ GCCount int
counters *testCounters
logBuff lockingBuffer
@@ -193,6 +194,9 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder {
if s.Cfg.Verbose || err != nil {
fmt.Println(s.logBuff.String())
}
+ if s.Cfg.RunGC {
+ s.GCCount, err = s.H.GC()
+ }
s.Assert(err, qt.IsNil)
return s
}
@@ -263,6 +267,7 @@ func (s *IntegrationTestBuilder) RenameFile(old, new string) *IntegrationTestBui
absNewFilename := s.absFilename(new)
s.renamedFiles = append(s.renamedFiles, absOldFilename)
s.createdFiles = append(s.createdFiles, absNewFilename)
+ s.Assert(s.fs.Source.MkdirAll(filepath.Dir(absNewFilename), 0777), qt.IsNil)
s.Assert(s.fs.Source.Rename(absOldFilename, absNewFilename), qt.IsNil)
return s
}
@@ -488,6 +493,9 @@ type IntegrationTestConfig struct {
// Whether it needs the real file system (e.g. for js.Build tests).
NeedsOsFS bool
+ // Whether to run GC after each build.
+ RunGC bool
+
// Do not remove the temp dir after the test.
PrintAndKeepTempDir bool