1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 19:40:07 +00:00

fix(tests): prevent permission dialogs during test runs

Add MOLE_TEST_MODE=1 checks to skip AppleScript osascript calls
and sudo operations that trigger system permission dialogs during tests:

- lib/check/all.sh: Skip login items listing
- lib/clean/apps.sh: Skip running app detection
- lib/clean/user.sh: Skip Finder trash operations and sudo test calls
- lib/core/log.sh: Skip sudo status check in debug log
- lib/uninstall/batch.sh: Skip login item removal

Also add MOLE_TEST_MODE=1 export to all test files that load
these modules to ensure consistent test isolation.
This commit is contained in:
Tw93
2026-03-16 20:43:35 +08:00
parent 0cc4862f9c
commit ea4cd9d0e3
13 changed files with 91 additions and 29 deletions

View File

@@ -303,8 +303,10 @@ log_system_info() {
fi
echo "Shell: ${SHELL:-unknown}, ${TERM:-unknown}"
# Check sudo status non-interactively
if sudo -n true 2> /dev/null; then
# Check sudo status non-interactively (skip in test mode)
if [[ "${MOLE_TEST_MODE:-0}" == "1" || "${MOLE_TEST_NO_AUTH:-0}" == "1" ]]; then
echo "Sudo Access: Skipped (test mode)"
elif sudo -n true 2> /dev/null; then
echo "Sudo Access: Active"
else
echo "Sudo Access: Required"