mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 16:45:07 +00:00
fix: explicitly skip system binary launch agents and harden test isolation
Add hint_is_system_binary() to short-circuit detection for plists that use /bin/*, /usr/bin/*, /usr/libexec/* etc. as their program path. These are custom scripts, not app-backed launch agents, so the stale detection logic does not apply. Previously the function relied on the absence of AssociatedBundleIdentifiers as an implicit skip, which could fail on certain macOS plutil edge cases. Also add teardown() in clean_hints.bats to explicitly remove the LaunchAgents directory after each test, and add run_with_timeout mock in the "skips custom shell wrappers" test to prevent mdfind from influencing results. This eliminates the intermittent failure where test 70 showed "Review:" in output without "Potential stale login item:".
This commit is contained in:
@@ -100,6 +100,19 @@ hint_is_app_scoped_launch_target() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2329
|
||||||
|
hint_is_system_binary() {
|
||||||
|
local program="$1"
|
||||||
|
|
||||||
|
case "$program" in
|
||||||
|
/bin/* | /sbin/* | /usr/bin/* | /usr/sbin/* | /usr/libexec/*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC2329
|
# shellcheck disable=SC2329
|
||||||
hint_launch_agent_bundle_exists() {
|
hint_launch_agent_bundle_exists() {
|
||||||
local bundle_id="$1"
|
local bundle_id="$1"
|
||||||
@@ -433,6 +446,9 @@ show_user_launch_agent_hint_notice() {
|
|||||||
local associated=""
|
local associated=""
|
||||||
|
|
||||||
program=$(hint_extract_launch_agent_program_path "$plist")
|
program=$(hint_extract_launch_agent_program_path "$plist")
|
||||||
|
if [[ -n "$program" ]] && hint_is_system_binary "$program"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if [[ -n "$program" ]] && hint_is_app_scoped_launch_target "$program" && [[ ! -e "$program" ]]; then
|
if [[ -n "$program" ]] && hint_is_app_scoped_launch_target "$program" && [[ ! -e "$program" ]]; then
|
||||||
reason="Missing app/helper target"
|
reason="Missing app/helper target"
|
||||||
target="${program/#$HOME/~}"
|
target="${program/#$HOME/~}"
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ setup() {
|
|||||||
mkdir -p "$HOME/.config/mole"
|
mkdir -p "$HOME/.config/mole"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
rm -rf "$HOME/Library/LaunchAgents"
|
||||||
|
}
|
||||||
|
|
||||||
@test "probe_project_artifact_hints reuses purge targets and excludes noisy names" {
|
@test "probe_project_artifact_hints reuses purge targets and excludes noisy names" {
|
||||||
local root="$HOME/hints-root"
|
local root="$HOME/hints-root"
|
||||||
mkdir -p "$root/proj/node_modules" "$root/proj/vendor" "$root/proj/bin"
|
mkdir -p "$root/proj/node_modules" "$root/proj/vendor" "$root/proj/bin"
|
||||||
@@ -153,6 +157,7 @@ set -euo pipefail
|
|||||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||||
source "$PROJECT_ROOT/lib/clean/hints.sh"
|
source "$PROJECT_ROOT/lib/clean/hints.sh"
|
||||||
note_activity() { :; }
|
note_activity() { :; }
|
||||||
|
run_with_timeout() { shift; "$@"; }
|
||||||
show_user_launch_agent_hint_notice
|
show_user_launch_agent_hint_notice
|
||||||
EOT5
|
EOT5
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user