1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 23:49:46 +00:00

System optimization and massive updates

This commit is contained in:
Tw93
2025-11-25 11:19:13 +08:00
parent 4aa50ac715
commit a19d525072
11 changed files with 440 additions and 101 deletions

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bats
setup_file() {
PROJECT_ROOT="$(cd "${BATS_TEST_DIRNAME}/.." && pwd)"
export PROJECT_ROOT
}
@test "run_with_timeout succeeds without GNU timeout" {
run bash --noprofile --norc -c '
set -euo pipefail
PATH="/usr/bin:/bin"
source "'"$PROJECT_ROOT"'/lib/common.sh"
run_with_timeout 1 sleep 0.1
'
[ "$status" -eq 0 ]
}
@test "run_with_timeout enforces timeout and returns 124" {
run bash --noprofile --norc -c '
set -euo pipefail
PATH="/usr/bin:/bin"
source "'"$PROJECT_ROOT"'/lib/common.sh"
run_with_timeout 1 sleep 5
'
[ "$status" -eq 124 ]
}

View File

@@ -97,3 +97,20 @@ setup() {
fi
[ "$status" -ne 0 ]
}
@test "mo clean --whitelist persists selections" {
whitelist_file="$HOME/.config/mole/whitelist"
mkdir -p "$(dirname "$whitelist_file")"
run bash --noprofile --norc -c "cd '$PROJECT_ROOT'; printf \$'\\n' | HOME='$HOME' ./mo clean --whitelist"
[ "$status" -eq 0 ]
grep -q "\\.m2/repository" "$whitelist_file"
run bash --noprofile --norc -c "cd '$PROJECT_ROOT'; printf \$' \\n' | HOME='$HOME' ./mo clean --whitelist"
[ "$status" -eq 0 ]
! grep -q "\\.m2/repository" "$whitelist_file"
run bash --noprofile --norc -c "cd '$PROJECT_ROOT'; printf \$'\\n' | HOME='$HOME' ./mo clean --whitelist"
[ "$status" -eq 0 ]
! grep -q "\\.m2/repository" "$whitelist_file"
}