mirror of
https://git.pumpin.online/funkpower/menologion.git
synced 2026-10-23 03:07:12 +00:00
the documented way to use this did not work
`import qs.horologion.modules` was the README's headline instruction and it
fails outright: Quickshell resolves `qs` against the host config root, not
the subtree, so in an empty shell the type is unavailable and in a populated
one the widget would have silently bound to the host's Config and Theme
instead of its own. The imports inside are now relative and each directory
carries a qmldir, so `import "horologion/modules"` works in any host and the
three pieces really are usable on their own.
- refresh() dropped a request made while a run was in flight, so a
jurisdiction or date set a moment after startup never took effect until
midnight. It queues now.
- The waybar script exited non-zero on its error paths, and waybar hides a
module whose script does that -- so a missing typikon made the module
vanish rather than say so, and the .error CSS was dead. An unrecognised
--format field raised instead of rendering empty, and the tooltip
interpolated unescaped text into Pango markup, which matters because
--update-menaion fetches commemorations from a page nobody here controls.
- The installer aborted the whole run at the point where it printed
'leaving it alone', and a wholly successful run exited 1 because the last
statement was a failed [ -d ] test under set -e. --help demanded typikon,
which is what --help would have told you to install.
- eww painted every day with the feast colour and printed a dangling
separator, because it compares against "" and eww renders a JSON null as
the string "null". The parenthesised ?: form two lines away was already
right. The week list also repeated today.
pip install typikon installed nothing; there is no such package, and that was
the first line of every install path. Pascha now carries its label instead of
being a bare ISO date in a corner.
tests/smoke.sh covers the scripts, which is where all of this lived and where
nothing was covered. It caught two of these while being written.
This commit is contained in:
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/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/horologion-waybar"
|
||||
install="$root/bin/horologion-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/horologion-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/horologion-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 ]
|
||||
Reference in New Issue
Block a user