aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-08-04 11:41:59 +0200
committerBjørn Erik Pedersen <[email protected]>2023-08-04 18:46:43 +0200
commit16da1ade7040a401fb704e9fae858a51ff517468 (patch)
tree27c9f478e1e6fafb43c066a1b8daace154db7218 /helpers
parenta3d42a277d3c492ce4a7860956234134e130aba1 (diff)
downloadhugo-16da1ade7040a401fb704e9fae858a51ff517468.tar.gz
hugo-16da1ade7040a401fb704e9fae858a51ff517468.zip
testing: Write test caches to /tmp
Fixes #11327
Diffstat (limited to 'helpers')
-rw-r--r--helpers/path.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 57877bfed..3172d3452 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -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"
@@ -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
+ }
}
}