diff --git a/mise.toml b/mise.toml index 0b55d40..1819228 100644 --- a/mise.toml +++ b/mise.toml @@ -22,6 +22,10 @@ description = 'Run test suite' depends = ['littlecheck'] file = 'scripts/test.fish' +[tasks.test-clean] +description = 'Remove the cached local test HOME used by `mise run test`' +file = 'scripts/test_clean.fish' + [tasks.clean] description = 'Remove generated test helper' run = 'rm -f littlecheck.py' diff --git a/scripts/test.fish b/scripts/test.fish index 99df253..fc1f950 100755 --- a/scripts/test.fish +++ b/scripts/test.fish @@ -20,8 +20,14 @@ exit \$test_status if test "$GITHUB_ACTIONS" = true #we can just have it work normally in CI, since it runs in a clean environment fish -c $inner_cmd else - set -l test_home (mktemp -d) + # Reuse a persistent HOME across local runs (shared across worktrees) so + # fisher/clownfish aren't reinstalled over the network every time. `fisher + # install .` still runs unconditionally, so local edits are always synced. + # Run `mise run test-clean` to wipe it if it ever gets into a bad state. + set -l cache_home $XDG_CACHE_HOME + test -n "$cache_home" || set cache_home $HOME/.cache + set -l test_home $cache_home/tide-test-home + mkdir -p $test_home env HOME=$test_home XDG_CONFIG_HOME=$test_home/.config fish -c $inner_cmd - command rm -rf $test_home end exit $status diff --git a/scripts/test_clean.fish b/scripts/test_clean.fish new file mode 100755 index 0000000..ea8fee7 --- /dev/null +++ b/scripts/test_clean.fish @@ -0,0 +1,12 @@ +#!/usr/bin/env fish + +set -l cache_home $XDG_CACHE_HOME +test -n "$cache_home" || set cache_home $HOME/.cache +set -l test_home $cache_home/tide-test-home + +if test -d $test_home + command rm -r $test_home + echo "Removed $test_home" +else + echo "Nothing to clean: $test_home does not exist" +end