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
+268
@@ -0,0 +1,268 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
helper="$repo_dir/config/dot/quickshell/scripts/panama-osd"
|
||||
scratch="$(mktemp -d)"
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
|
||||
mkdir -p "$scratch/bin"
|
||||
log="$scratch/calls"
|
||||
|
||||
cat >"$scratch/bin/wpctl" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'wpctl' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
if [[ $1 == "get-volume" ]]; then
|
||||
printf '%s\n' "${WPCTL_OUTPUT:-Volume: 0.58}"
|
||||
fi
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/brightnessctl" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'brightnessctl' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
if [[ " $* " == *" -m "* && " $* " != *" set "* ]]; then
|
||||
[[ ${BACKLIGHT_AVAILABLE:-true} == true ]] || exit 1
|
||||
printf '%s\n' "${BRIGHTNESS_OUTPUT:-intel_backlight,backlight,500,50%,1000}"
|
||||
fi
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/panama-brightness" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'panama-brightness' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
|
||||
case "${1:-}" in
|
||||
list)
|
||||
if [[ -n ${DDC_LIST_JSON:-} ]]; then
|
||||
printf '%s\n' "$DDC_LIST_JSON"
|
||||
else
|
||||
printf '%s\n' '{"displays":[],"error":"No displays"}'
|
||||
fi
|
||||
;;
|
||||
get)
|
||||
[[ ${DDC_FAIL_GET_BUS:-} != "${2:-}" ]] || exit 1
|
||||
if [[ -s $OSD_DDC_STATE ]]; then
|
||||
cat "$OSD_DDC_STATE"
|
||||
else
|
||||
printf '%s\n' "${DDC_GET_VALUE:-40}"
|
||||
fi
|
||||
;;
|
||||
set)
|
||||
if [[ -n ${DDC_SET_DELAY:-} ]]; then
|
||||
if ! mkdir "$OSD_DDC_PROBE" 2>/dev/null; then
|
||||
printf 'ddc-overlap\n' >>"$OSD_TEST_LOG"
|
||||
fi
|
||||
sleep "$DDC_SET_DELAY"
|
||||
rmdir "$OSD_DDC_PROBE" 2>/dev/null || true
|
||||
fi
|
||||
printf '%s\n' "${3:-0}" >"$OSD_DDC_STATE"
|
||||
;;
|
||||
*) exit 2 ;;
|
||||
esac
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/hyprctl" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'hyprctl' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
printf '[{"name":"%s","focused":true}]\n' "${FOCUSED_MONITOR:-DP-2}"
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/notify-send" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'notify-send' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/playerctl" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'playerctl' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
if [[ $1 == "metadata" ]]; then
|
||||
printf '%s\n' "${PLAYER_OUTPUT:-Horizon — Tycho}"
|
||||
elif [[ $1 == "status" ]]; then
|
||||
printf '%s\n' "${PLAYER_STATUS:-Playing}"
|
||||
fi
|
||||
SH
|
||||
|
||||
cat >"$scratch/bin/qs" <<'SH'
|
||||
#!/bin/bash
|
||||
printf 'qs' >>"$OSD_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$OSD_TEST_LOG"
|
||||
printf '\n' >>"$OSD_TEST_LOG"
|
||||
[[ ${OSD_TEST_FAIL_QS:-false} != true ]]
|
||||
SH
|
||||
|
||||
chmod +x "$scratch/bin/"*
|
||||
|
||||
run_helper() {
|
||||
local runtime="${OSD_RUNTIME_DIR:-$scratch/runtime-default}"
|
||||
mkdir -p "$runtime"
|
||||
PATH="$scratch/bin:$PATH" OSD_TEST_LOG="$log" \
|
||||
OSD_TEST_FAIL_QS="${OSD_TEST_FAIL_QS:-false}" \
|
||||
PANAMA_OSD_STRICT="${PANAMA_OSD_STRICT:-false}" \
|
||||
PANAMA_OSD_BRIGHTNESS_HELPER="$scratch/bin/panama-brightness" \
|
||||
PANAMA_OSD_RUNTIME_DIR="$runtime" \
|
||||
OSD_DDC_STATE="$runtime/ddc-state" \
|
||||
OSD_DDC_PROBE="$runtime/ddc-probe" \
|
||||
BACKLIGHT_AVAILABLE="${BACKLIGHT_AVAILABLE:-true}" \
|
||||
DDC_LIST_JSON="${DDC_LIST_JSON:-}" \
|
||||
DDC_GET_VALUE="${DDC_GET_VALUE:-40}" \
|
||||
DDC_FAIL_GET_BUS="${DDC_FAIL_GET_BUS:-}" \
|
||||
DDC_SET_DELAY="${DDC_SET_DELAY:-}" \
|
||||
FOCUSED_MONITOR="${FOCUSED_MONITOR:-DP-2}" \
|
||||
"$helper" "$@"
|
||||
}
|
||||
|
||||
assert_line() {
|
||||
local expected="$1"
|
||||
grep -Fqx -- "$expected" "$log" || {
|
||||
printf 'osd helper contract: missing call\n%s\nactual:\n' "$expected" >&2
|
||||
cat "$log" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
: >"$log"
|
||||
run_helper volume up 6
|
||||
assert_line 'wpctl <set-volume> <-l> <1> <@DEFAULT_AUDIO_SINK@> <6%+>'
|
||||
assert_line 'wpctl <get-volume> <@DEFAULT_AUDIO_SINK@>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <volume> <58> <100> <58%>'
|
||||
|
||||
: >"$log"
|
||||
WPCTL_OUTPUT='Volume: 0.58 [MUTED]' run_helper volume toggle
|
||||
assert_line 'wpctl <set-mute> <@DEFAULT_AUDIO_SINK@> <toggle>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <volume-muted> <58> <100> <Muted>'
|
||||
|
||||
: >"$log"
|
||||
WPCTL_OUTPUT='Volume: 0.72 [MUTED]' run_helper microphone toggle
|
||||
assert_line 'wpctl <set-mute> <@DEFAULT_AUDIO_SOURCE@> <toggle>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <microphone-muted> <72> <100> <Muted>'
|
||||
|
||||
: >"$log"
|
||||
run_helper brightness up 5
|
||||
assert_line 'brightnessctl <-m> <-c> <backlight>'
|
||||
assert_line 'brightnessctl <-e4> <-n2> <-c> <backlight> <set> <5%+>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <brightness> <50> <100> <50%>'
|
||||
if grep -Fq 'panama-brightness' "$log"; then
|
||||
printf 'osd helper contract: DDC fallback ran despite a native backlight\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":3,"connector":"HDMI-A-1","value":35},{"bus":5,"connector":"DP-2","value":40}],"error":""}' \
|
||||
run_helper brightness up 5
|
||||
assert_line 'hyprctl <-j> <monitors>'
|
||||
assert_line 'panama-brightness <list>'
|
||||
assert_line 'panama-brightness <get> <5>'
|
||||
assert_line 'panama-brightness <set> <5> <45>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <brightness> <45> <100> <45%>'
|
||||
|
||||
# A cached bus avoids the expensive display scan on subsequent key presses.
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":3,"connector":"HDMI-A-1","value":35},{"bus":5,"connector":"DP-2","value":45}],"error":""}' \
|
||||
run_helper brightness down 5
|
||||
assert_line 'panama-brightness <get> <5>'
|
||||
assert_line 'panama-brightness <set> <5> <40>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <brightness> <40> <100> <40%>'
|
||||
if grep -Fq 'panama-brightness <list>' "$log"; then
|
||||
printf 'osd helper contract: cached DDC bus triggered another display scan\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# A disconnected cached monitor is discarded and rediscovered once.
|
||||
mkdir -p "$scratch/runtime-ddc-stale"
|
||||
printf '9\tDP-9\n' >"$scratch/runtime-ddc-stale/brightness-bus"
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc-stale" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_FAIL_GET_BUS=9 \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":5,"connector":"DP-2","value":40}],"error":""}' \
|
||||
run_helper brightness up 5
|
||||
assert_line 'panama-brightness <get> <9>'
|
||||
assert_line 'panama-brightness <list>'
|
||||
assert_line 'panama-brightness <get> <5>'
|
||||
assert_line 'panama-brightness <set> <5> <45>'
|
||||
|
||||
# If the focused output is not DDC-capable, use the first discovered display.
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc-first" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
FOCUSED_MONITOR='eDP-1' \
|
||||
DDC_GET_VALUE=35 \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":3,"connector":"HDMI-A-1","value":35},{"bus":5,"connector":"DP-2","value":40}],"error":""}' \
|
||||
run_helper brightness down 10
|
||||
assert_line 'panama-brightness <get> <3>'
|
||||
assert_line 'panama-brightness <set> <3> <25>'
|
||||
assert_line 'qs <ipc> <call> <osd> <progress> <brightness> <25> <100> <25%>'
|
||||
|
||||
# Permission and discovery errors must be visible, never masquerade as 0%.
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc-error" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_LIST_JSON='{"displays":[],"error":"Run sudo udevadm control --reload-rules && sudo udevadm trigger --subsystem-match=i2c-dev --subsystem-match=drm"}' \
|
||||
run_helper brightness up 5
|
||||
assert_line 'qs <ipc> <call> <osd> <message> <dialog-warning-symbolic> <Brightness needs permission>'
|
||||
assert_line 'notify-send <--app-name=Panama> <--icon=display-brightness-symbolic> <Brightness unavailable> <Run sudo udevadm control --reload-rules && sudo udevadm trigger --subsystem-match=i2c-dev --subsystem-match=drm>'
|
||||
if grep -Fq 'osd> <progress> <brightness>' "$log"; then
|
||||
printf 'osd helper contract: unavailable brightness rendered a false percentage\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Separate key-repeat processes must not overlap their DDC transactions.
|
||||
: >"$log"
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc-lock" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_SET_DELAY=0.15 \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":5,"connector":"DP-2","value":40}],"error":""}' \
|
||||
run_helper brightness up 5 &
|
||||
first_pid=$!
|
||||
OSD_RUNTIME_DIR="$scratch/runtime-ddc-lock" \
|
||||
BACKLIGHT_AVAILABLE=false \
|
||||
DDC_SET_DELAY=0.15 \
|
||||
DDC_LIST_JSON='{"displays":[{"bus":5,"connector":"DP-2","value":40}],"error":""}' \
|
||||
run_helper brightness up 5 &
|
||||
second_pid=$!
|
||||
wait "$first_pid"
|
||||
wait "$second_pid"
|
||||
if grep -Fqx 'ddc-overlap' "$log"; then
|
||||
printf 'osd helper contract: concurrent DDC transactions overlapped\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(<"$scratch/runtime-ddc-lock/ddc-state") != 50 ]]; then
|
||||
printf 'osd helper contract: serialized key repeats did not both apply\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: >"$log"
|
||||
run_helper media next
|
||||
assert_line 'playerctl <next>'
|
||||
assert_line 'qs <ipc> <call> <osd> <message> <media-next> <Horizon — Tycho>'
|
||||
|
||||
: >"$log"
|
||||
run_helper message notifications-disabled-symbolic 'Do Not Disturb On'
|
||||
assert_line 'qs <ipc> <call> <osd> <message> <notifications-disabled-symbolic> <Do Not Disturb On>'
|
||||
|
||||
: >"$log"
|
||||
if OSD_TEST_FAIL_QS=true PANAMA_OSD_STRICT=1 run_helper message dialog-error-symbolic 'Strict failure'; then
|
||||
printf 'osd helper contract: strict delivery swallowed an IPC failure\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: >"$log"
|
||||
OSD_TEST_FAIL_QS=true run_helper message dialog-information-symbolic 'Best effort'
|
||||
|
||||
printf 'osd helper contract: PASS\n'
|
||||
Reference in New Issue
Block a user