build: keep the DVD and MQTT helpers, and count the deletion honestly
Building the package showed what reading the tree did not: classroom-dvd still calls classroom-window, classroom-mqtt still calls classroom-notify, and the DVD overlay still imports the icon and stylesheet helpers the dock shared. They go back in, and the write-up now counts what was actually removed rather than what could be. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
6e4786f448
commit
4c3f19d599
@@ -3,7 +3,7 @@ set -uo pipefail
|
||||
|
||||
# Tests the session resolution in classroom-notify-test.
|
||||
#
|
||||
# sway is stood in for by a real background process started with a known
|
||||
# The compositor is stood in for by a real background process started with a known
|
||||
# environment, so /proc/<pid>/environ is genuine rather than mocked. id,
|
||||
# pgrep, runuser and notify-send are shimmed onto PATH so every branch
|
||||
# can be reached from an ordinary account.
|
||||
@@ -14,7 +14,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SCRIPT="$ROOT/scripts/classroom-notify"
|
||||
|
||||
WORK="$(mktemp -d)"
|
||||
trap 'rm -rf "$WORK"; kill "${FAKE_SWAY_PID:-}" 2>/dev/null' EXIT
|
||||
trap 'rm -rf "$WORK"; kill "${FAKE_SESSION_PID:-}" 2>/dev/null' EXIT
|
||||
|
||||
passed=0
|
||||
failed=0
|
||||
@@ -67,12 +67,12 @@ SHIM
|
||||
cat > "$WORK/bin/pgrep" <<'SHIM'
|
||||
#!/bin/bash
|
||||
case "${!#}" in
|
||||
sway)
|
||||
[[ -n "${FAKE_SWAY_PID:-}" ]] || exit 1
|
||||
echo "$FAKE_SWAY_PID"
|
||||
kwin_wayland)
|
||||
[[ -n "${FAKE_SESSION_PID:-}" ]] || exit 1
|
||||
echo "$FAKE_SESSION_PID"
|
||||
;;
|
||||
mako)
|
||||
[[ "${FAKE_MAKO:-1}" == "1" ]] || exit 1
|
||||
plasmashell)
|
||||
[[ "${FAKE_SHELL:-1}" == "1" ]] || exit 1
|
||||
echo 4242
|
||||
;;
|
||||
*)
|
||||
@@ -120,27 +120,27 @@ run() {
|
||||
"$SCRIPT" "$@" 2>&1
|
||||
}
|
||||
|
||||
start_fake_sway() {
|
||||
start_fake_session() {
|
||||
env "$@" sleep 300 &
|
||||
FAKE_SWAY_PID=$!
|
||||
export FAKE_SWAY_PID
|
||||
FAKE_SESSION_PID=$!
|
||||
export FAKE_SESSION_PID
|
||||
# Give the exec time to land so /proc/<pid>/environ is populated.
|
||||
while [[ ! -r "/proc/$FAKE_SWAY_PID/environ" ]]; do sleep 0.05; done
|
||||
while [[ ! -r "/proc/$FAKE_SESSION_PID/environ" ]]; do sleep 0.05; done
|
||||
}
|
||||
|
||||
stop_fake_sway() {
|
||||
[[ -n "${FAKE_SWAY_PID:-}" ]] && kill "$FAKE_SWAY_PID" 2>/dev/null
|
||||
wait "${FAKE_SWAY_PID:-}" 2>/dev/null
|
||||
unset FAKE_SWAY_PID
|
||||
stop_fake_session() {
|
||||
[[ -n "${FAKE_SESSION_PID:-}" ]] && kill "$FAKE_SESSION_PID" 2>/dev/null
|
||||
wait "${FAKE_SESSION_PID:-}" 2>/dev/null
|
||||
unset FAKE_SESSION_PID
|
||||
}
|
||||
|
||||
unset WAYLAND_DISPLAY DBUS_SESSION_BUS_ADDRESS
|
||||
|
||||
# --------------------------------------------- 1. resolve from environ
|
||||
|
||||
echo "1. resolves the session from sway's environment"
|
||||
echo "1. resolves the session from the compositor's environment"
|
||||
|
||||
start_fake_sway \
|
||||
start_fake_session \
|
||||
XDG_RUNTIME_DIR="$RUNTIME" \
|
||||
DBUS_SESSION_BUS_ADDRESS="unix:path=$RUNTIME/bus" \
|
||||
WAYLAND_DISPLAY=wayland-7
|
||||
@@ -149,9 +149,9 @@ out="$(run)"
|
||||
check "reports delivery to the classroom session" "Sent normal notification to the classroom desktop session" "$out"
|
||||
|
||||
log="$(cat "$NOTIFY_LOG")"
|
||||
check "runtime dir taken from sway" "XDG_RUNTIME_DIR=$RUNTIME" "$log"
|
||||
check "bus address taken from sway" "DBUS_SESSION_BUS_ADDRESS=unix:path=$RUNTIME/bus" "$log"
|
||||
check "wayland display from sway" "WAYLAND_DISPLAY=wayland-7" "$log"
|
||||
check "runtime dir taken from the compositor" "XDG_RUNTIME_DIR=$RUNTIME" "$log"
|
||||
check "bus address taken from the compositor" "DBUS_SESSION_BUS_ADDRESS=unix:path=$RUNTIME/bus" "$log"
|
||||
check "wayland display from the compositor" "WAYLAND_DISPLAY=wayland-7" "$log"
|
||||
check "styling preserved" "--app-name=Ekklesia Classroom" "$log"
|
||||
check "default sample title" "DVD Ready" "$log"
|
||||
check "default sample body" "A disc is ready to play." "$log"
|
||||
@@ -161,7 +161,7 @@ check "default sample body" "A disc is ready to play."
|
||||
echo "2. --dry-run reports the resolved session and sends nothing"
|
||||
|
||||
out="$(run --dry-run)"
|
||||
check "shows the sway pid" "sway pid: $FAKE_SWAY_PID" "$out"
|
||||
check "shows the compositor pid" "compositor pid: $FAKE_SESSION_PID" "$out"
|
||||
check "shows the runtime dir" "XDG_RUNTIME_DIR: $RUNTIME" "$out"
|
||||
check "shows the wayland display" "WAYLAND_DISPLAY: wayland-7" "$out"
|
||||
check_absent "nothing was sent" "args:" "$(cat "$NOTIFY_LOG")"
|
||||
@@ -196,35 +196,35 @@ check "explains it needs root" "run this as root (sudo classroom-notify)" "$out"
|
||||
check_absent "nothing was sent" "args:" "$(cat "$NOTIFY_LOG")"
|
||||
FAKE_CURRENT_UID=4000
|
||||
|
||||
# ----------------------------------------- 6. mako must already be up
|
||||
# ------------------------------- 6. the shell must already be up
|
||||
|
||||
echo "6. refuses to let D-Bus start a second mako"
|
||||
echo "6. refuses to let D-Bus start a notification service"
|
||||
|
||||
export FAKE_MAKO=0
|
||||
export FAKE_SHELL=0
|
||||
out="$(run)"
|
||||
check "explains mako is not running" "mako is not running in the classroom session" "$out"
|
||||
check "explains the shell is not running" "the classroom shell is not running" "$out"
|
||||
check_absent "nothing was sent" "args:" "$(cat "$NOTIFY_LOG")"
|
||||
unset FAKE_MAKO
|
||||
unset FAKE_SHELL
|
||||
|
||||
stop_fake_sway
|
||||
stop_fake_session
|
||||
|
||||
# --------------------------------- 7. display derived from the lock fd
|
||||
|
||||
echo "7. derives the display from sway's wayland lock when environ has none"
|
||||
echo "7. derives the display from the compositor's wayland lock when environ has none"
|
||||
|
||||
touch "$RUNTIME/wayland-9.lock"
|
||||
env -u WAYLAND_DISPLAY \
|
||||
XDG_RUNTIME_DIR="$RUNTIME" \
|
||||
DBUS_SESSION_BUS_ADDRESS="unix:path=$RUNTIME/bus" \
|
||||
bash -c "exec 9< '$RUNTIME/wayland-9.lock'; sleep 300" &
|
||||
FAKE_SWAY_PID=$!
|
||||
export FAKE_SWAY_PID
|
||||
while [[ ! -r "/proc/$FAKE_SWAY_PID/fd/9" ]]; do sleep 0.05; done
|
||||
FAKE_SESSION_PID=$!
|
||||
export FAKE_SESSION_PID
|
||||
while [[ ! -r "/proc/$FAKE_SESSION_PID/fd/9" ]]; do sleep 0.05; done
|
||||
|
||||
out="$(run --dry-run)"
|
||||
check "display derived from the lock" "WAYLAND_DISPLAY: wayland-9" "$out"
|
||||
|
||||
stop_fake_sway
|
||||
stop_fake_session
|
||||
|
||||
# ------------------------------------------- 8. no session at all
|
||||
|
||||
@@ -236,9 +236,9 @@ check_absent "nothing was sent" "args:" "$(cat "$NOTIFY_LOG")"
|
||||
|
||||
# ------------------------------------- 9. falls back when environ is thin
|
||||
|
||||
echo "9. falls back to session defaults when sway's environment is unreadable"
|
||||
echo "9. falls back to session defaults when the compositor's environment is unreadable"
|
||||
|
||||
start_fake_sway XDG_RUNTIME_DIR="$RUNTIME"
|
||||
start_fake_session XDG_RUNTIME_DIR="$RUNTIME"
|
||||
|
||||
out="$(run --dry-run)"
|
||||
check "derives the bus from the runtime dir" \
|
||||
@@ -249,7 +249,7 @@ check "still delivers" "Sent normal notification to the classroom desktop sessio
|
||||
check "bus reached notify-send" "DBUS_SESSION_BUS_ADDRESS=unix:path=$RUNTIME/bus" \
|
||||
"$(cat "$NOTIFY_LOG")"
|
||||
|
||||
stop_fake_sway
|
||||
stop_fake_session
|
||||
|
||||
# ------------------------------------------ 10. missing bus is explained
|
||||
|
||||
@@ -257,19 +257,19 @@ echo "10. explains a missing session bus instead of hanging"
|
||||
|
||||
MISSING="$WORK/empty"
|
||||
mkdir -p "$MISSING"
|
||||
start_fake_sway XDG_RUNTIME_DIR="$MISSING"
|
||||
start_fake_session XDG_RUNTIME_DIR="$MISSING"
|
||||
|
||||
out="$(run)"
|
||||
check "names the missing socket" "bus socket $MISSING/bus does not exist" "$out"
|
||||
check_absent "nothing was sent" "args:" "$(cat "$NOTIFY_LOG")"
|
||||
|
||||
stop_fake_sway
|
||||
stop_fake_session
|
||||
|
||||
# ----------------------------- 11. already inside the classroom session
|
||||
|
||||
echo "11. sends directly when already inside the classroom session"
|
||||
|
||||
# No sway process to find: an in-session caller must not need one.
|
||||
# No compositor process to find: an in-session caller must not need one.
|
||||
export WAYLAND_DISPLAY=wayland-4
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$RUNTIME/bus"
|
||||
export XDG_RUNTIME_DIR="$RUNTIME"
|
||||
|
||||
Reference in New Issue
Block a user