mirror of
https://github.com/go-task/task.git
synced 2026-07-07 22:18:47 +00:00
feat: Add temp dir option (#2891)
Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ type TaskRC struct {
|
||||
Interactive *bool `yaml:"interactive"`
|
||||
Remote Remote `yaml:"remote"`
|
||||
Failfast bool `yaml:"failfast"`
|
||||
TempDir *string `yaml:"temp-dir"`
|
||||
Experiments map[string]int `yaml:"experiments"`
|
||||
}
|
||||
|
||||
@@ -70,4 +71,5 @@ func (t *TaskRC) Merge(other *TaskRC) {
|
||||
t.Concurrency = cmp.Or(other.Concurrency, t.Concurrency)
|
||||
t.Interactive = cmp.Or(other.Interactive, t.Interactive)
|
||||
t.Failfast = cmp.Or(other.Failfast, t.Failfast)
|
||||
t.TempDir = cmp.Or(other.TempDir, t.TempDir)
|
||||
}
|
||||
|
||||
@@ -112,6 +112,40 @@ func TestGetConfig_OnlyLocal(t *testing.T) { //nolint:paralleltest // cannot run
|
||||
}, cfg)
|
||||
}
|
||||
|
||||
func TestGetConfig_TempDir(t *testing.T) { //nolint:paralleltest // cannot run in parallel
|
||||
_, _, localDir := setupDirs(t)
|
||||
|
||||
writeFile(t, localDir, ".taskrc.yml", `
|
||||
temp-dir: .task-cache
|
||||
`)
|
||||
|
||||
cfg, err := GetConfig(localDir)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, cfg)
|
||||
require.NotNil(t, cfg.TempDir)
|
||||
assert.Equal(t, ".task-cache", *cfg.TempDir)
|
||||
}
|
||||
|
||||
func TestGetConfig_TempDirMergePrecedence(t *testing.T) { //nolint:paralleltest // cannot run in parallel
|
||||
xdgConfigDir, homeDir, localDir := setupDirs(t)
|
||||
|
||||
writeFile(t, xdgConfigDir, "taskrc.yml", `
|
||||
temp-dir: xdg-cache
|
||||
`)
|
||||
writeFile(t, homeDir, ".taskrc.yml", `
|
||||
temp-dir: home-cache
|
||||
`)
|
||||
writeFile(t, localDir, ".taskrc.yml", `
|
||||
temp-dir: local-cache
|
||||
`)
|
||||
|
||||
cfg, err := GetConfig(localDir)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, cfg)
|
||||
require.NotNil(t, cfg.TempDir)
|
||||
assert.Equal(t, "local-cache", *cfg.TempDir)
|
||||
}
|
||||
|
||||
func TestGetConfig_All(t *testing.T) { //nolint:paralleltest // cannot run in parallel
|
||||
xdgConfigDir, homeDir, localDir := setupDirs(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user