1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-07 11:03:29 +00:00

feat: optimize clean operation performance by pre-expanding whitelist patterns, improving size calculation, and adapting parallel processing based on file types, alongside test suite enhancements.

This commit is contained in:
Tw93
2025-12-30 17:13:43 +08:00
parent 41ce597f02
commit 6c1fcd23d7
6 changed files with 207 additions and 86 deletions

View File

@@ -28,7 +28,7 @@ setup() {
}
@test "mo clean --dry-run skips system cleanup in non-interactive mode" {
run env HOME="$HOME" "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
[[ "$output" == *"Dry Run Mode"* ]]
[[ "$output" != *"Deep system-level cleanup"* ]]
@@ -38,7 +38,7 @@ setup() {
mkdir -p "$HOME/Library/Caches/TestApp"
echo "cache data" > "$HOME/Library/Caches/TestApp/cache.tmp"
run env HOME="$HOME" "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
[[ "$output" == *"User app cache"* ]]
[[ "$output" == *"Potential space"* ]]
@@ -53,7 +53,7 @@ setup() {
$HOME/Library/Caches/WhitelistedApp*
EOF
run env HOME="$HOME" "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
[[ "$output" == *"Protected"* ]]
[ -f "$HOME/Library/Caches/WhitelistedApp/data.tmp" ]
@@ -63,7 +63,7 @@ EOF
mkdir -p "$HOME/.m2/repository/org/example"
echo "dependency" > "$HOME/.m2/repository/org/example/lib.jar"
run env HOME="$HOME" "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
[ -f "$HOME/.m2/repository/org/example/lib.jar" ]
[[ "$output" != *"Maven repository cache"* ]]

View File

@@ -27,7 +27,7 @@ setup() {
}
@test "mo clean --debug creates debug log file" {
run env HOME="$HOME" MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
MOLE_OUTPUT="$output"
@@ -44,14 +44,14 @@ setup() {
}
@test "mo clean without debug does not show debug log path" {
run env HOME="$HOME" MO_DEBUG=0 "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 MO_DEBUG=0 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
[[ "$output" != *"Debug session log saved to"* ]]
}
@test "mo clean --debug logs system info" {
run env HOME="$HOME" MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run
run env HOME="$HOME" MOLE_TEST_MODE=1 MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ]
DEBUG_LOG="$HOME/.config/mole/mole_debug_session.log"