Skip to content

Commit

Permalink
testing: Write test caches to /tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Aug 4, 2023
1 parent 61be050 commit f2a0c8b
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 f2a0c8b

Please sign in to comment.