Drop the extension, and give the test suite a front door
Phase 6, the last of the fresh-install spec. 159 scripts lose their .sh: 110 contracts, 47 Vicinae commands, 2 compositor contracts. A shebang and the executable bit already select the interpreter. The extension only ever added something that had to stay in sync, and the rename proved the point twice over in the space of an hour. The spec's stated risk was Vicinae's script discovery. One script was renamed and reloaded on its own before the other 46 followed; it came back as scripts:panama.capture and all 47 resolve. What the probe turned up instead is that the extension was never only a filename: Vicinae's command IDs embed it, so every ID changed. Nothing in this repository refers to them, so nothing breaks. The only trace is Vicinae's metadata.json, whose visited map had two Panama entries that are now orphaned -- two commands lost their usage ranking and will earn it back. Worth knowing before anyone renames these again on a machine that has a keybind pointing at one. Rewriting the references by exact filename missed two things it structurally could not see: a name built from a variable, settings-$page.sh, and a glob, -name '*.sh'. Both were in the contract that counts the generated commands, which promptly reported 47 expected and 0 found. The mechanical part of a rename is the part that looks finished. The three subcommands. panama doctor fronts a health check that already existed and already ran at the end of every install but could not be reached from a terminal. panama upgrade re-runs the installer from anywhere. panama test runs the suite, which had no entry point at all -- 121 files that were the main safety net in this repository and were invisible in it. Writing that runner found three tests nothing was running. calendar_agenda_bridge_test, home_assistant_bridge_test and kdeconnect_bridge_test are unittest suites without the executable bit, so no contract invoked them and the first draft of the runner skipped them silently. All three pass, and have passed unobserved for weeks. The runner collects *_test.py as well now, because a runner with a blind spot is worse than no runner for the same reason a dependency checker with one is: it reports PASS. Six worktrees pruned. Each was re-checked rather than trusted to the spec's list, and two needed it: panama-commands is not on feat/panama-commands but on feat/gnome-tweaks-parity, and fix/panama-displays-review reads [ahead 3] -- ahead of its remote, not of main, with every commit patch-equivalent to landed work. roadmap-completion stays; it has five commits that are genuinely unlanded. The branches are left alone: pruning a worktree costs nothing, deleting a branch is a decision. 121 contracts pass. Claude-Session: https://claude.ai/code/session_01NvgBuSWB5sE43yWmg21ozj
This commit is contained in:
Executable
+233
@@ -0,0 +1,233 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
dispatcher="$repo_dir/config/dot/quickshell/scripts/panama-action"
|
||||
work="$(mktemp -d /tmp/panama-action.XXXXXX)"
|
||||
fake_bin="$work/bin"
|
||||
command_log="$work/commands.log"
|
||||
|
||||
fail() {
|
||||
printf 'Panama action contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$work"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
[[ -x "$dispatcher" ]] || fail 'dispatcher is missing or not executable'
|
||||
|
||||
mkdir -p "$fake_bin" "$work/home/.config/quickshell/scripts"
|
||||
|
||||
make_recorder() {
|
||||
local command_name="$1"
|
||||
cp /dev/stdin "$fake_bin/$command_name"
|
||||
chmod +x "$fake_bin/$command_name"
|
||||
}
|
||||
|
||||
make_recorder qs <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'qs' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
case "$*" in
|
||||
'ipc call notifications dnd'|'ipc call caffeine toggle'|'ipc call night-light toggle')
|
||||
printf '%s\n' "${PANAMA_ACTION_TEST_STATE:-true}"
|
||||
;;
|
||||
'ipc call focus start'|'ipc call focus end')
|
||||
printf '%s\n' "${PANAMA_ACTION_TEST_FOCUS_STATE:-true}"
|
||||
;;
|
||||
esac
|
||||
if [[ ${PANAMA_ACTION_TEST_FAIL_KILL:-false} == true && ${1:-} == kill ]]; then
|
||||
exit 1
|
||||
fi
|
||||
[[ ${PANAMA_ACTION_TEST_FAIL_QS:-false} != true ]]
|
||||
EOF
|
||||
|
||||
make_recorder quickshell <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'quickshell' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder panama-osd <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'panama-osd' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
[[ ${PANAMA_ACTION_TEST_FAIL_OSD:-false} != true ]]
|
||||
EOF
|
||||
|
||||
make_recorder panama-prism-gallery <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'panama-prism-gallery' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
if (( $# > 0 )); then
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
fi
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder notify-send <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'notify-send' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder systemd-inhibit <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
if [[ -n ${PANAMA_ACTION_TEST_INHIBITOR_FILE:-} && -s $PANAMA_ACTION_TEST_INHIBITOR_FILE ]]; then
|
||||
while IFS= read -r pid; do
|
||||
printf 'Panama 1000 gib %s systemd-inhibit sleep:idle Caffeine block\n' "$pid"
|
||||
done <"$PANAMA_ACTION_TEST_INHIBITOR_FILE"
|
||||
exit 0
|
||||
fi
|
||||
if [[ ${PANAMA_ACTION_TEST_CONFIRMED_STATE:-${PANAMA_ACTION_TEST_STATE:-true}} == true ]]; then
|
||||
printf 'Panama 1000 gib 42 systemd-inhibit sleep:idle Caffeine block\n'
|
||||
fi
|
||||
EOF
|
||||
|
||||
make_recorder kill <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'kill' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
if [[ -n ${PANAMA_ACTION_TEST_INHIBITOR_FILE:-} ]]; then
|
||||
: >"$PANAMA_ACTION_TEST_INHIBITOR_FILE"
|
||||
fi
|
||||
EOF
|
||||
|
||||
make_recorder pgrep <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
[[ ${PANAMA_ACTION_TEST_CONFIRMED_STATE:-${PANAMA_ACTION_TEST_STATE:-true}} == true ]]
|
||||
EOF
|
||||
|
||||
make_recorder id <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf '1000\n'
|
||||
EOF
|
||||
|
||||
run_action() {
|
||||
: >"$command_log"
|
||||
HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_HELPER_DIR="$fake_bin" \
|
||||
PANAMA_ACTION_KILL_COMMAND="$fake_bin/kill" \
|
||||
PANAMA_ACTION_CONFIRM_ATTEMPTS=1 \
|
||||
PANAMA_ACTION_CONFIRM_DELAY=0 \
|
||||
PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" "$1"
|
||||
}
|
||||
|
||||
assert_commands() {
|
||||
local expected="$1"
|
||||
local actual
|
||||
actual="$(cat "$command_log")"
|
||||
[[ "$actual" == "$expected" ]] \
|
||||
|| fail "wrong command sequence; expected [$expected], got [$actual]"
|
||||
}
|
||||
|
||||
run_action control-center
|
||||
assert_commands 'qs <ipc> <call> <quicksettings> <open>'
|
||||
|
||||
run_action notifications
|
||||
assert_commands 'qs <ipc> <call> <notifications> <open>'
|
||||
|
||||
run_action calendar
|
||||
assert_commands 'qs <ipc> <call> <calendar-agenda> <open>'
|
||||
|
||||
run_action clipboard
|
||||
assert_commands 'qs <ipc> <call> <clipboard> <open>'
|
||||
|
||||
run_action overview
|
||||
assert_commands 'qs <ipc> <call> <overview> <open>'
|
||||
|
||||
run_action settings
|
||||
assert_commands 'qs <ipc> <call> <settings> <open>'
|
||||
|
||||
run_action health
|
||||
assert_commands 'qs <ipc> <call> <health> <open>'
|
||||
|
||||
run_action dnd
|
||||
assert_commands $'qs <ipc> <call> <notifications> <dnd>\npanama-osd <message> <notifications-disabled-symbolic> <Do Not Disturb On>'
|
||||
|
||||
PANAMA_ACTION_TEST_STATE=false run_action caffeine
|
||||
assert_commands $'qs <ipc> <call> <caffeine> <toggle>\npanama-osd <message> <weather-clear-night-symbolic> <Caffeine Off>'
|
||||
|
||||
printf '4242\n' >"$work/inhibitors"
|
||||
PANAMA_ACTION_TEST_STATE=false PANAMA_ACTION_TEST_INHIBITOR_FILE="$work/inhibitors" run_action caffeine
|
||||
assert_commands $'qs <ipc> <call> <caffeine> <toggle>\nkill <4242>\npanama-osd <message> <weather-clear-night-symbolic> <Caffeine Off>'
|
||||
|
||||
run_action night-light
|
||||
assert_commands $'qs <ipc> <call> <night-light> <toggle>\npanama-osd <message> <night-light-symbolic> <Night Light On>'
|
||||
|
||||
run_action focus-start
|
||||
assert_commands $'qs <ipc> <call> <focus> <start>\npanama-osd <message> <preferences-system-time-symbolic> <Focus Session Started>'
|
||||
|
||||
run_action focus-end
|
||||
assert_commands $'qs <ipc> <call> <focus> <end>\npanama-osd <message> <media-playback-stop-symbolic> <Focus Session Ended>'
|
||||
|
||||
PANAMA_ACTION_TEST_FOCUS_STATE=false run_action focus-end
|
||||
assert_commands $'qs <ipc> <call> <focus> <end>\npanama-osd <message> <dialog-information-symbolic> <No Focus Session Running>'
|
||||
|
||||
run_action capture
|
||||
assert_commands 'qs <ipc> <call> <capture> <open>'
|
||||
|
||||
run_action intelligence
|
||||
assert_commands 'qs <ipc> <call> <screen-intelligence> <open>'
|
||||
|
||||
run_action screenshot
|
||||
assert_commands 'qs <ipc> <call> <capture> <screenNow>'
|
||||
|
||||
run_action microphone
|
||||
assert_commands 'panama-osd <microphone> <toggle>'
|
||||
|
||||
run_action gallery
|
||||
assert_commands 'panama-prism-gallery'
|
||||
|
||||
run_action restart-shell
|
||||
assert_commands $'qs <kill>\nquickshell <--daemonize>\nqs <ipc> <show>\npanama-osd <message> <view-refresh-symbolic> <Panama Restarted>'
|
||||
|
||||
PANAMA_ACTION_TEST_FAIL_KILL=true run_action restart-shell
|
||||
assert_commands $'qs <kill>\nquickshell <--daemonize>\nqs <ipc> <show>\npanama-osd <message> <view-refresh-symbolic> <Panama Restarted>'
|
||||
|
||||
usage_output="$work/usage.txt"
|
||||
if HOME="$work/home" PATH="$fake_bin:$PATH" PANAMA_ACTION_HELPER_DIR="$fake_bin" \
|
||||
PANAMA_ACTION_CONFIRM_ATTEMPTS=1 PANAMA_ACTION_CONFIRM_DELAY=0 PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" definitely-not-an-action > /dev/null 2>"$usage_output"; then
|
||||
fail 'unknown action was accepted'
|
||||
fi
|
||||
rg -q '\bhealth\b' "$usage_output" || fail 'health is missing from dispatcher usage'
|
||||
|
||||
: >"$command_log"
|
||||
if PANAMA_ACTION_TEST_FAIL_QS=true HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_HELPER_DIR="$fake_bin" PANAMA_ACTION_CONFIRM_ATTEMPTS=1 \
|
||||
PANAMA_ACTION_CONFIRM_DELAY=0 PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" control-center >/dev/null 2>&1; then
|
||||
fail 'failed shell action returned success'
|
||||
fi
|
||||
assert_commands $'qs <ipc> <call> <quicksettings> <open>\nnotify-send <-a> <Panama> <-i> <dialog-error-symbolic> <Panama action failed> <The “control center” action could not be completed.>'
|
||||
|
||||
: >"$command_log"
|
||||
if PANAMA_ACTION_TEST_FAIL_OSD=true HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_HELPER_DIR="$fake_bin" PANAMA_ACTION_CONFIRM_ATTEMPTS=1 \
|
||||
PANAMA_ACTION_CONFIRM_DELAY=0 PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" microphone >/dev/null 2>&1; then
|
||||
fail 'failed Prism OSD delivery returned success'
|
||||
fi
|
||||
assert_commands $'panama-osd <microphone> <toggle>\nnotify-send <-a> <Panama> <-i> <dialog-error-symbolic> <Panama action failed> <The “microphone” action could not be completed.>'
|
||||
|
||||
: >"$command_log"
|
||||
if PANAMA_ACTION_TEST_CONFIRMED_STATE=false HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_HELPER_DIR="$fake_bin" PANAMA_ACTION_CONFIRM_ATTEMPTS=1 \
|
||||
PANAMA_ACTION_CONFIRM_DELAY=0 PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" caffeine >/dev/null 2>&1; then
|
||||
fail 'unconfirmed Caffeine state returned success'
|
||||
fi
|
||||
grep -Fqx 'notify-send <-a> <Panama> <-i> <dialog-error-symbolic> <Panama action failed> <The “caffeine” action could not be completed.>' "$command_log" \
|
||||
|| fail 'unconfirmed state did not send a failure notification'
|
||||
|
||||
printf 'Panama action contract: PASS\n'
|
||||
Reference in New Issue
Block a user