mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 21:55:08 +00:00
feat(clean): expand conservative cache cleanup coverage
- add conservative support/app/system cache targets\n- fix dry-run + success logging behavior for memory exception cleanup\n- add regression tests for new cleanup paths and safeguards\n\nRefs #477
This commit is contained in:
@@ -58,6 +58,56 @@ EOF
|
||||
[[ "$output" == *"Saved application states"* ]] || [[ "$output" == *"App caches"* ]]
|
||||
}
|
||||
|
||||
@test "clean_support_app_data targets crash, wallpaper, and messages preview caches only" {
|
||||
local support_home="$HOME/support-cache-home-1"
|
||||
run env HOME="$support_home" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
mkdir -p "$HOME"
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
source "$PROJECT_ROOT/lib/clean/user.sh"
|
||||
safe_clean() { echo "$2"; }
|
||||
safe_find_delete() { echo "FIND:$1:$3:$4"; }
|
||||
pgrep() { return 1; }
|
||||
|
||||
mkdir -p "$HOME/Library/Application Support/CrashReporter"
|
||||
mkdir -p "$HOME/Library/Application Support/com.apple.idleassetsd"
|
||||
|
||||
clean_support_app_data
|
||||
|
||||
rm -rf "$HOME/Library/Application Support/CrashReporter"
|
||||
rm -rf "$HOME/Library/Application Support/com.apple.idleassetsd"
|
||||
EOF
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"FIND:$support_home/Library/Application Support/CrashReporter:30:f"* ]]
|
||||
[[ "$output" == *"FIND:$support_home/Library/Application Support/com.apple.idleassetsd:30:f"* ]]
|
||||
[[ "$output" == *"Messages sticker cache"* ]]
|
||||
[[ "$output" == *"Messages preview attachment cache"* ]]
|
||||
[[ "$output" == *"Messages preview sticker cache"* ]]
|
||||
[[ "$output" != *"Messages attachments"* ]]
|
||||
}
|
||||
|
||||
@test "clean_support_app_data skips messages preview caches while Messages is running" {
|
||||
local support_home="$HOME/support-cache-home-2"
|
||||
run env HOME="$support_home" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
mkdir -p "$HOME"
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
source "$PROJECT_ROOT/lib/clean/user.sh"
|
||||
safe_clean() { echo "$2"; }
|
||||
safe_find_delete() { :; }
|
||||
pgrep() { return 0; }
|
||||
|
||||
clean_support_app_data
|
||||
EOF
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Messages is running"* ]]
|
||||
[[ "$output" != *"Messages sticker cache"* ]]
|
||||
[[ "$output" != *"Messages preview attachment cache"* ]]
|
||||
[[ "$output" != *"Messages preview sticker cache"* ]]
|
||||
}
|
||||
|
||||
@test "clean_app_caches skips protected containers" {
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" DRY_RUN=true /bin/bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
Reference in New Issue
Block a user