summaryrefslogtreecommitdiffstats
path: root/hugolib/integrationtest_builder.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-21 09:35:15 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-08 13:26:17 +0200
commitd070bdf10f14d233288f7318a4e9f7555f070a65 (patch)
treefff8d59f98bdab3027bb45c4e10ca88594332872 /hugolib/integrationtest_builder.go
parentb08193971a821fc27e549a73120c15e5e5186775 (diff)
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
Diffstat (limited to 'hugolib/integrationtest_builder.go')
-rw-r--r--hugolib/integrationtest_builder.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index d49e29763..e5c9a6856 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -47,6 +47,8 @@ func NewIntegrationTestBuilder(conf IntegrationTestConfig) *IntegrationTestBuild
if doClean {
c.Cleanup(clean)
}
+ } else if conf.WorkingDir == "" {
+ conf.WorkingDir = helpers.FilePathSeparator
}
return &IntegrationTestBuilder{
@@ -157,7 +159,7 @@ func (s *IntegrationTestBuilder) AssertDestinationExists(filename string, b bool
}
func (s *IntegrationTestBuilder) destinationExists(filename string) bool {
- b, err := helpers.Exists(filename, s.fs.Destination)
+ b, err := helpers.Exists(filename, s.fs.PublishDir)
if err != nil {
panic(err)
}
@@ -258,11 +260,7 @@ func (s *IntegrationTestBuilder) RenameFile(old, new string) *IntegrationTestBui
func (s *IntegrationTestBuilder) FileContent(filename string) string {
s.Helper()
- filename = filepath.FromSlash(filename)
- if !strings.HasPrefix(filename, s.Cfg.WorkingDir) {
- filename = filepath.Join(s.Cfg.WorkingDir, filename)
- }
- return s.readDestination(s, s.fs, filename)
+ return s.readWorkingDir(s, s.fs, filepath.FromSlash(filename))
}
func (s *IntegrationTestBuilder) initBuilder() {
@@ -280,8 +278,6 @@ func (s *IntegrationTestBuilder) initBuilder() {
logger := loggers.NewBasicLoggerForWriter(s.Cfg.LogLevel, &s.logBuff)
- fs := hugofs.NewFrom(afs, config.New())
-
for _, f := range s.data.Files {
filename := filepath.Join(s.Cfg.WorkingDir, f.Name)
s.Assert(afs.MkdirAll(filepath.Dir(filename), 0777), qt.IsNil)
@@ -301,10 +297,12 @@ func (s *IntegrationTestBuilder) initBuilder() {
},
)
- s.Assert(err, qt.IsNil)
-
cfg.Set("workingDir", s.Cfg.WorkingDir)
+ fs := hugofs.NewFrom(afs, cfg)
+
+ s.Assert(err, qt.IsNil)
+
depsCfg := deps.DepsCfg{Cfg: cfg, Fs: fs, Running: s.Cfg.Running, Logger: logger}
sites, err := NewHugoSites(depsCfg)
s.Assert(err, qt.IsNil)
@@ -400,9 +398,9 @@ func (s *IntegrationTestBuilder) changeEvents() []fsnotify.Event {
return events
}
-func (s *IntegrationTestBuilder) readDestination(t testing.TB, fs *hugofs.Fs, filename string) string {
+func (s *IntegrationTestBuilder) readWorkingDir(t testing.TB, fs *hugofs.Fs, filename string) string {
t.Helper()
- return s.readFileFromFs(t, fs.Destination, filename)
+ return s.readFileFromFs(t, fs.WorkingDirReadOnly, filename)
}
func (s *IntegrationTestBuilder) readFileFromFs(t testing.TB, fs afero.Fs, filename string) string {