mirror of
https://git.pumpin.online/funkpower/menologion.git
synced 2026-10-22 18:57:14 +00:00
The Horologion is the Book of Hours: the fixed portions of the services themselves. This shows the day's commemorations, its fast and its season, which is a Menologion. Naming it for a book whose contents it does not carry was a real error and worth the churn to correct. typikon already uses the word internally, for menologion.py and the data file it loads. That is not a collision: typikon provides a menologion, this displays one. Renamed throughout, not just the repo: the two scripts, the QML component and its three qmldir modules, MENOLOGION_COLORS, ~/.config/menologion/colors.json, the eww widgets and scss variables, the waybar class. Verified standalone and embedded in a foreign shell, and the smoke suite still passes. Also drops the em dashes from the prose.
85 lines
3.7 KiB
Bash
Executable File
85 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Smoke tests for the front ends. Run: tests/smoke.sh
|
|
#
|
|
# These exist because every bug found in the first review of this repo was in
|
|
# the shell and Python around the QML, not in the QML: a --format field that
|
|
# raised, an installer that aborted where it said it was continuing, an error
|
|
# path that exited non-zero so waybar hid the message it was trying to show.
|
|
# None of it was covered by anything.
|
|
set -uo pipefail
|
|
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
waybar="$root/bin/menologion-waybar"
|
|
install="$root/bin/menologion-install"
|
|
pass=0 fail=0
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
bad() { fail=$((fail+1)); printf ' FAIL %s\n %s\n' "$1" "${2:-}"; }
|
|
|
|
check() { # check <name> <expected-exit> <cmd...>
|
|
local name="$1" want="$2"; shift 2
|
|
local out; out="$("$@" 2>&1)"; local got=$?
|
|
[ "$got" = "$want" ] || { bad "$name" "exit $got, wanted $want"; return; }
|
|
ok "$name"
|
|
}
|
|
|
|
json() { # json <name> <cmd...> -- stdout must parse
|
|
local name="$1"; shift
|
|
local out; out="$("$@" 2>/dev/null)"
|
|
if printf '%s' "$out" | python3 -c 'import json,sys; json.load(sys.stdin)' 2>/dev/null
|
|
then ok "$name"; else bad "$name" "not JSON: ${out:0:80}"; fi
|
|
}
|
|
|
|
echo
|
|
echo " waybar module"
|
|
command -v typikon >/dev/null 2>&1 || { echo " SKIP: typikon not on PATH"; exit 77; }
|
|
json "plain run emits JSON" "$waybar"
|
|
json "an unknown --format field" "$waybar" --format '{nosuchfield}'
|
|
json "a positional --format field" "$waybar" --format '{0}'
|
|
json "an unclosed --format brace" "$waybar" --format '{'
|
|
json "--no-emoji" "$waybar" --no-emoji
|
|
json "--days 1" "$waybar" --days 1
|
|
json "an unknown jurisdiction" "$waybar" -j atlantis
|
|
# waybar hides a module whose script exits non-zero, so every path must be 0
|
|
# or the error JSON is never read.
|
|
# A PATH that still has an interpreter but no typikon -- typikon installs to
|
|
# ~/.local/bin, which this leaves out. Emptying PATH entirely would only prove
|
|
# that the shebang cannot find python3.
|
|
check "exit 0 when typikon is missing" 0 env PATH=/usr/bin:/bin "$waybar"
|
|
json "JSON when typikon is missing" env PATH=/usr/bin:/bin "$waybar"
|
|
check "exit 0 on a bad jurisdiction" 0 "$waybar" -j atlantis
|
|
|
|
out="$("$waybar" --format '{daysToPascha}' 2>/dev/null)"
|
|
case "$out" in
|
|
*'"text": ""'*) bad "a zero field is not blanked" "daysToPascha rendered empty" ;;
|
|
*) ok "a zero field is not blanked" ;;
|
|
esac
|
|
|
|
echo
|
|
echo " installer"
|
|
check "--help without typikon" 0 env PATH=/usr/bin:/bin "$install" --help
|
|
check "an unknown subcommand" 2 "$install" nonsense
|
|
mkdir -p "$tmp/a/.config/quickshell" "$tmp/a/.config/waybar"
|
|
check "a clean run with eww absent" 0 env HOME="$tmp/a" XDG_CONFIG_HOME="$tmp/a/.config" "$install" all
|
|
mkdir -p "$tmp/b/.local/bin" "$tmp/b/.config"; : > "$tmp/b/.local/bin/menologion-waybar"
|
|
check "a real file at the target" 1 env HOME="$tmp/b" XDG_CONFIG_HOME="$tmp/b/.config" "$install" all
|
|
[ -L "$tmp/a/.local/bin/menologion-waybar" ] \
|
|
&& ok "the clean run actually linked" || bad "the clean run actually linked"
|
|
|
|
echo
|
|
echo " syntax"
|
|
check "installer parses" 0 bash -n "$install"
|
|
check "waybar module compiles" 0 python3 -m py_compile "$waybar"
|
|
rm -rf "$root/bin/__pycache__"
|
|
for f in "$root"/quickshell/*.qml "$root"/quickshell/*/*.qml; do
|
|
[ -f "$f" ] || continue
|
|
grep -q . "$f" || bad "empty QML: $f"
|
|
done
|
|
ok "QML files are non-empty"
|
|
|
|
echo
|
|
printf ' %d passed, %d failed\n\n' "$pass" "$fail"
|
|
[ "$fail" -eq 0 ]
|