mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix(clean): speed up Python bytecode cache cleanup
This commit is contained in:
@@ -212,7 +212,9 @@ clean_project_caches() {
|
|||||||
[[ -d "$cache_dir/cache" ]] && safe_clean "$cache_dir/cache"/* "Next.js build cache" || true
|
[[ -d "$cache_dir/cache" ]] && safe_clean "$cache_dir/cache"/* "Next.js build cache" || true
|
||||||
;;
|
;;
|
||||||
"__pycache__")
|
"__pycache__")
|
||||||
[[ -d "$cache_dir" ]] && safe_clean "$cache_dir"/* "Python bytecode cache" || true
|
# Remove the cache directory itself so we avoid expanding every
|
||||||
|
# .pyc file into a separate safe_clean target.
|
||||||
|
[[ -d "$cache_dir" ]] && safe_clean "$cache_dir" "Python bytecode cache" || true
|
||||||
;;
|
;;
|
||||||
".dart_tool")
|
".dart_tool")
|
||||||
if [[ -d "$cache_dir" ]]; then
|
if [[ -d "$cache_dir" ]]; then
|
||||||
|
|||||||
@@ -138,6 +138,25 @@ setup() {
|
|||||||
rm -rf "$HOME/Projects"
|
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" {
|
@test "clean_project_caches scans configured roots instead of HOME" {
|
||||||
mkdir -p "$HOME/.config/mole"
|
mkdir -p "$HOME/.config/mole"
|
||||||
mkdir -p "$HOME/CustomProjects/app/.next/cache"
|
mkdir -p "$HOME/CustomProjects/app/.next/cache"
|
||||||
|
|||||||
Reference in New Issue
Block a user