1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 21:20:09 +00:00

fix(clean): speed up Python bytecode cache cleanup

This commit is contained in:
tw93
2026-03-08 19:45:53 +08:00
parent 4df6c9c531
commit 24da1e2ac1
2 changed files with 22 additions and 1 deletions

View File

@@ -138,6 +138,25 @@ setup() {
rm -rf "$HOME/Projects"
}
@test "clean_project_caches removes pycache directories as single targets" {
mkdir -p "$HOME/Projects/python-app/__pycache__"
touch "$HOME/Projects/python-app/pyproject.toml"
touch "$HOME/Projects/python-app/__pycache__/module.pyc"
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"
safe_clean() { echo "$2|$1"; }
clean_project_caches
EOF
[ "$status" -eq 0 ]
[[ "$output" == *"Python bytecode cache|$HOME/Projects/python-app/__pycache__"* ]]
[[ "$output" != *"module.pyc"* ]]
rm -rf "$HOME/Projects"
}
@test "clean_project_caches scans configured roots instead of HOME" {
mkdir -p "$HOME/.config/mole"
mkdir -p "$HOME/CustomProjects/app/.next/cache"