mirror of https://github.com/perkeep/perkeep.git
pkmountTest: ensure tests don't share cache
Also introduce PERKEEP_CACHE_DIR so we can deprecate CAMLI_CACHE_DIR at some point.
This commit is contained in:
parent
317e9f5490
commit
457318579e
|
@ -59,6 +59,9 @@ func CacheDir() string {
|
|||
}
|
||||
|
||||
func cacheDir() string {
|
||||
if d := os.Getenv("PERKEEP_CACHE_DIR"); d != "" {
|
||||
return d
|
||||
}
|
||||
if d := os.Getenv("CAMLI_CACHE_DIR"); d != "" {
|
||||
return d
|
||||
}
|
||||
|
@ -72,15 +75,15 @@ func cacheDir() string {
|
|||
// both. This seems to work.
|
||||
for _, ev := range []string{"TEMP", "TMP"} {
|
||||
if v := os.Getenv(ev); v != "" {
|
||||
return filepath.Join(v, "Camlistore")
|
||||
return filepath.Join(v, "Perkeep")
|
||||
}
|
||||
}
|
||||
panic("No Windows TEMP or TMP environment variables found; please file a bug report.")
|
||||
}
|
||||
if xdg := os.Getenv("XDG_CACHE_HOME"); xdg != "" {
|
||||
return filepath.Join(xdg, "camlistore")
|
||||
return filepath.Join(xdg, "perkeep")
|
||||
}
|
||||
return filepath.Join(HomeDir(), ".cache", "camlistore")
|
||||
return filepath.Join(HomeDir(), ".cache", "perkeep")
|
||||
}
|
||||
|
||||
func makeCacheDir() {
|
||||
|
|
|
@ -142,15 +142,7 @@ func pkmountTest(t *testing.T, fn func(env *mountEnv)) {
|
|||
defer log.SetOutput(os.Stderr)
|
||||
|
||||
w := test.GetWorld(t)
|
||||
mountPoint, err := ioutil.TempDir("", "fs-test-mount")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
if err := os.RemoveAll(mountPoint); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
mountPoint := t.TempDir()
|
||||
verbose := "false"
|
||||
var stderrDest io.Writer = ioutil.Discard
|
||||
if v, _ := strconv.ParseBool(os.Getenv("VERBOSE_FUSE")); v {
|
||||
|
@ -161,7 +153,15 @@ func pkmountTest(t *testing.T, fn func(env *mountEnv)) {
|
|||
stderrDest = io.MultiWriter(stderrDest, os.Stderr)
|
||||
}
|
||||
|
||||
mount := w.Cmd("pk-mount", "--debug="+verbose, mountPoint)
|
||||
mount := w.CmdWithEnv(
|
||||
"pk-mount",
|
||||
append(
|
||||
os.Environ(),
|
||||
"PERKEEP_CACHE_DIR="+t.TempDir(),
|
||||
),
|
||||
"--debug="+verbose,
|
||||
mountPoint,
|
||||
)
|
||||
mount.Stderr = stderrDest
|
||||
mount.Env = append(mount.Env, "CAMLI_TRACK_FS_STATS=1")
|
||||
|
||||
|
|
Loading…
Reference in New Issue