Skip to content

Commit

Permalink
testing: Write test caches to /tmp
Browse files Browse the repository at this point in the history
Fixes #11327
  • Loading branch information
bep committed Aug 4, 2023
1 parent a3d42a2 commit 16da1ad
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions helpers/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/text"
"github.com/gohugoio/hugo/htesting"

"github.com/gohugoio/hugo/hugofs"

Expand Down Expand Up @@ -411,11 +412,14 @@ func GetCacheDir(fs afero.Fs, cacheDir string) (string, error) {

const hugoCacheBase = "hugo_cache"

userCacheDir, err := os.UserCacheDir()
if err == nil {
cacheDir := filepath.Join(userCacheDir, hugoCacheBase)
if err := fs.Mkdir(cacheDir, 0777); err == nil || os.IsExist(err) {
return cacheDir, nil
// Avoid filling up the home dir with Hugo cache dirs from development.
if !htesting.IsTest {
userCacheDir, err := os.UserCacheDir()
if err == nil {
cacheDir := filepath.Join(userCacheDir, hugoCacheBase)
if err := fs.Mkdir(cacheDir, 0777); err == nil || os.IsExist(err) {
return cacheDir, nil
}
}
}

Expand Down

0 comments on commit 16da1ad

Please sign in to comment.