mirror of
https://github.com/tw93/Mole.git
synced 2026-03-24 04:20:07 +00:00
fix: dedupe cleanup previews by filesystem identity
This commit is contained in:
@@ -125,6 +125,18 @@ PLIST
|
||||
[ -f "$HOME/Library/LaunchAgents/com.example.stale.plist" ]
|
||||
}
|
||||
|
||||
@test "mo clean --dry-run does not export duplicate targets across sections" {
|
||||
mkdir -p "$HOME/Library/Application Support/Code/CachedData"
|
||||
echo "cache" > "$HOME/Library/Application Support/Code/CachedData/data.bin"
|
||||
|
||||
run env HOME="$HOME" MOLE_TEST_MODE=0 "$PROJECT_ROOT/mole" clean --dry-run
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
run grep -c "Application Support/Code/CachedData" "$HOME/.config/mole/clean-list.txt"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "mo clean honors whitelist entries" {
|
||||
mkdir -p "$HOME/Library/Caches/WhitelistedApp"
|
||||
echo "keep me" > "$HOME/Library/Caches/WhitelistedApp/data.tmp"
|
||||
|
||||
@@ -238,6 +238,25 @@ EOF
|
||||
rm -rf "$HOME/go"
|
||||
}
|
||||
|
||||
@test "discover_project_cache_roots dedupes aliased roots by filesystem identity" {
|
||||
mkdir -p "$HOME/code/demo/.dart_tool"
|
||||
touch "$HOME/code/demo/pubspec.yaml"
|
||||
mkdir -p "$HOME/.config/mole"
|
||||
ln -s "$HOME/code" "$HOME/Code"
|
||||
printf '%s\n' "$HOME/Code" > "$HOME/.config/mole/purge_paths"
|
||||
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
source "$PROJECT_ROOT/lib/clean/caches.sh"
|
||||
roots=$(discover_project_cache_roots)
|
||||
printf '%s\n' "$roots"
|
||||
printf 'COUNT=%s\n' "$(printf '%s\n' "$roots" | sed '/^$/d' | wc -l | tr -d ' ')"
|
||||
EOF
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"COUNT=1"* ]]
|
||||
}
|
||||
|
||||
@test "clean_project_caches skips stalled root scans" {
|
||||
mkdir -p "$HOME/.config/mole"
|
||||
mkdir -p "$HOME/SlowProjects/app"
|
||||
|
||||
Reference in New Issue
Block a user