Files
HamPack/tests/update.bats
T
David YoungandClaude Opus 5.5 cdba8b45e7 Add xara, a VARA-compatible modem, alongside VARA under Wine
- compile.conf: build xara 0.1.3 with cargo, without the "registered"
  feature; stage-install xara, xara-monitor, man pages, the user
  service (pointed at ~/.local/bin) and the CM108/AIOC PTT udev rule;
  copy the config template to ~/.config/xara/xara.conf if it's not
  there. The service isn't enabled: it needs a callsign, and shares
  port 8300 with VARA
- packages.conf: alsa-lib and libpulse; rust only when there's no cargo
  yet, since it conflicts with rustup
- hampackremove: stop and disable the xara service, keep the user's
  settings and say where they are
- README: how to set up xara and use it with Pat
- tests for the xara build, the rust/cargo check and removal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:16:08 -07:00

118 lines
4.0 KiB
Bash

#!/usr/bin/env bats
#
# update.sh as run on first install (by install.sh) and on later updates
# (by CoreDesktop's `update`)
load helpers
setup() {
setup_fake_home
fake_coredesktop
# No apps to download or build; those scripts have their own tests
export HAMPACK_BINARIES_CONF="$BATS_TEST_TMPDIR/empty.conf"
export HAMPACK_COMPILE_CONF="$BATS_TEST_TMPDIR/empty.conf"
: > "$HAMPACK_BINARIES_CONF"
local data="$BATS_TEST_TMPDIR/uv-tools/not1mm/lib/python3.13/site-packages/not1mm/data"
mkdir -p "$data"
touch "$data/k6gte-not1mm.desktop"
export UV_TOOL_DIR="$BATS_TEST_TMPDIR/uv-tools"
stub uv '
case "$1 $2" in
"tool list") [ -f "$HOME/not1mm" ] && echo "not1mm v1.0" ;;
"tool install") touch "$HOME/not1mm" ;;
"tool dir") echo "$UV_TOOL_DIR" ;;
esac
exit 0'
}
@test "first install records only the packages and Flatpaks it installed" {
mark_installed cmake wine
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"HamPack updated."* ]]
# Everything on the list is installed now
local pkg
for pkg in $(all_hampack_packages); do [ -f "$FAKE_PACMAN_DB/$pkg" ]; done
# but what was there before isn't recorded as HamPack's
! grep -qx cmake "$HAMPACK_STATE/installed-packages"
! grep -qx wine "$HAMPACK_STATE/installed-packages"
grep -qx hamlib "$HAMPACK_STATE/installed-packages"
[ "$(wc -l < "$HAMPACK_STATE/installed-flatpaks")" -eq "$(all_hampack_flatpaks | wc -l)" ]
grep -qx "uv tool install not1mm" "$STUB_LOG"
[ -x "$HOME/.local/bin/hampackremove" ]
}
@test "a later update installs and records nothing new" {
bash "$REPO/update.sh"
cp "$HAMPACK_STATE/installed-packages" "$BATS_TEST_TMPDIR/before"
: > "$STUB_LOG"
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
! grep -q '^yay -S' "$STUB_LOG"
! grep -q '^flatpak install' "$STUB_LOG"
grep -qx "uv tool upgrade not1mm" "$STUB_LOG"
cmp "$HAMPACK_STATE/installed-packages" "$BATS_TEST_TMPDIR/before"
}
@test "an update after install from before records: existing packages aren't claimed" {
local pkg
for pkg in $(all_hampack_packages); do mark_installed "$pkg"; done
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
[ ! -s "$HAMPACK_STATE/installed-packages" ]
}
@test "update removes stale state from older HamPack versions" {
mkdir -p "$HAMPACK_STATE"
printf 'Kiwix-Desktop=2.75.1\nkiwix-desktop=2.5.1\nKiwix-Tools=3.8.2\n' > "$HAMPACK_STATE/.installed_versions"
touch "$HOME/.local/bin/hampackupdate"
run bash "$REPO/update.sh"
[ "$(cat "$HAMPACK_STATE/.installed_versions")" = "kiwix-desktop=2.5.1" ]
[ ! -e "$HOME/.local/bin/hampackupdate" ]
grep -qx "sudo rm -f /etc/sudoers.d/hampack" "$STUB_LOG"
}
@test "graywolf's service is installed and enabled once graywolf is built" {
run bash "$REPO/update.sh"
! grep -q "graywolf.service" "$STUB_LOG"
touch "$HOME/.local/bin/graywolf"
chmod +x "$HOME/.local/bin/graywolf"
: > "$STUB_LOG"
run bash "$REPO/update.sh"
[ "$status" -eq 0 ]
grep -qx "sudo tee /etc/systemd/system/graywolf.service" "$STUB_LOG"
grep -qx "enable_services graywolf" "$STUB_LOG"
}
@test "the graywolf web UI listens only on this machine" {
grep -q -- "-http 127.0.0.1:8080" "$REPO/systemd/graywolf.service"
}
@test "a failing step is reported and the rest still run" {
stub flatpak 'exit 1'
run bash "$REPO/update.sh"
[ "$status" -eq 1 ]
[[ "$output" == *"errors in: Installing Flatpak applications"* ]]
grep -qx "uv tool install not1mm" "$STUB_LOG"
}
@test "rust is installed for xara only when there's no cargo" {
stub cargo 'exit 0'
run bash "$REPO/update.sh"
[ ! -e "$FAKE_PACMAN_DB/rust" ]
# A PATH with everything but cargo
local nocargo="$BATS_TEST_TMPDIR/nocargo" dir f
mkdir -p "$nocargo"
rm "$STUB_DIR/cargo"
for dir in /usr/local/bin /usr/bin; do
for f in "$dir"/*; do
[ "$(basename "$f")" = cargo ] || ln -sf "$f" "$nocargo/" 2> /dev/null
done
done
PATH="$STUB_DIR:$nocargo" run bash "$REPO/update.sh"
[ -e "$FAKE_PACMAN_DB/rust" ]
grep -qx rust "$HAMPACK_STATE/installed-packages"
}