From ec1c97e7e9d62ce5245135e0906fdedf14af0cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 4 Mar 2023 11:09:03 +0100 Subject: 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 --- hugolib/integrationtest_builder.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'hugolib') 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 -- cgit v1.2.3