Automatically approve orphan removal during updates (#14428)
This commit is contained in:
1 parent
2fa6d0ecc5
commit
402128b6a2
5 files changed
+41
-10
No files matched your search
@@ -23,7 +23,7 @@ SH
|
||||
}
|
||||
|
||||
run_orphan_checker() {
|
||||
HOME="$test_home" PATH="$stub_bin:$PATH" "$ROOT/bin/omarchy-update-orphan-pkgs"
|
||||
HOME="$test_home" PATH="$stub_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-update-orphan-pkgs" "$@"
|
||||
}
|
||||
|
||||
write_stub pacman 'if [[ $1 == "-Qtdq" ]]; then printf "old-lib\nunused-tool\n"; exit 0; fi; exit 1'
|
||||
@@ -35,7 +35,29 @@ grep -q '^ old-lib$' "$test_tmp/noninteractive.out" || fail "orphan checker lis
|
||||
grep -q 'Re-run omarchy-update-orphan-pkgs in a terminal' "$test_tmp/noninteractive.out" || fail "orphan checker does not remove packages non-interactively"
|
||||
pass "orphan checker only reports orphans non-interactively"
|
||||
|
||||
export REMOVAL_LOG="$test_tmp/removal.log"
|
||||
write_stub pacman 'case $1 in
|
||||
-Qtdq|-Qq) printf "old-lib\nunused-tool\n" ;;
|
||||
-Rns) printf "%s\n" "$@" >"$REMOVAL_LOG" ;;
|
||||
*) exit 1 ;;
|
||||
esac'
|
||||
write_stub sudo '"$@"'
|
||||
run_orphan_checker -y >"$test_tmp/approved.out" 2>"$test_tmp/approved.err"
|
||||
diff <(printf '%s\n' -Rns --noconfirm old-lib unused-tool) "$REMOVAL_LOG" ||
|
||||
fail "approved cleanup removes the orphan packages without pacman confirmation"
|
||||
pass "approved cleanup removes orphans without Omarchy or pacman confirmation"
|
||||
|
||||
write_stub sudo 'exit 42'
|
||||
if run_orphan_checker -y >"$test_tmp/failure.out" 2>"$test_tmp/failure.err"; then
|
||||
fail "approved cleanup reports removal failures"
|
||||
fi
|
||||
pass "approved cleanup reports removal failures"
|
||||
|
||||
rm -f "$REMOVAL_LOG"
|
||||
write_stub pacman 'if [[ $1 == "-Qtdq" ]]; then exit 0; fi; exit 1'
|
||||
run_orphan_checker >"$test_tmp/none.out" 2>"$test_tmp/none.err"
|
||||
[[ ! -s $test_tmp/none.out ]] || fail "orphan checker stays quiet when no orphans exist"
|
||||
for mode in "" -y; do
|
||||
run_orphan_checker $mode >"$test_tmp/none.out" 2>"$test_tmp/none.err"
|
||||
[[ ! -s $test_tmp/none.out ]] || fail "orphan checker stays quiet when no orphans exist"
|
||||
done
|
||||
[[ ! -e $REMOVAL_LOG ]] || fail "orphan checker does not remove packages when no orphans exist"
|
||||
pass "orphan checker stays quiet without orphans"
|
||||
Reference in new issue
Block a user