`hampackcheck packages` (and `make check-packages`) checks that every package in packages.conf is in the repos or on the AUR and every Flatpak is on Flathub, and fails if any is missing or couldn't be checked. Names only provided by another package pass with a note. New tests cover hampackcheck's version comparisons and package check, and check compile.conf, binaries.conf, packages.conf and the desktop files for missing or misspelt fields and paths that don't exist. A Gitea workflow runs lint and tests on every push and pull request, and the package check on those and weekly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.6 KiB
Bash
84 lines
2.6 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
setup_fake_home
|
|
SRC="$BATS_TEST_TMPDIR/src"
|
|
mkdir -p "$SRC"
|
|
echo "v1" > "$SRC/tool"
|
|
SHA="$(sha256sum "$SRC/tool" | cut -d' ' -f1)"
|
|
export HAMPACK_BINARIES_CONF="$BATS_TEST_TMPDIR/binaries.conf"
|
|
}
|
|
|
|
write_conf() {
|
|
cat > "$HAMPACK_BINARIES_CONF" << EOF
|
|
[tool]
|
|
version=$1
|
|
url=file://$SRC/tool
|
|
sha256=$2
|
|
install=\$HOME/.local/bin/tool
|
|
gui=true
|
|
comment=A test tool
|
|
icon=\$HAMPACK_DIR/desktop/icons/paracon.png
|
|
EOF
|
|
}
|
|
|
|
@test "first install downloads, verifies, records the version and writes the desktop file" {
|
|
write_conf 1.0 "$SHA"
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ -x "$HOME/.local/bin/tool" ]
|
|
[ "$(cat "$HAMPACK_STATE/.installed_versions")" = "tool=1.0" ]
|
|
grep -qx "Categories=HamRadio;" "$HOME/.local/share/applications/tool.desktop"
|
|
grep -qx "Icon=$REPO/desktop/icons/paracon.png" "$HOME/.local/share/applications/tool.desktop"
|
|
}
|
|
|
|
@test "a download that doesn't match its sha256 isn't installed" {
|
|
write_conf 1.0 0000000000000000000000000000000000000000000000000000000000000000
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"doesn't match its sha256"* ]]
|
|
[ ! -e "$HOME/.local/bin/tool" ]
|
|
[ -z "$(grep tool= "$HAMPACK_STATE/.installed_versions" 2> /dev/null)" ]
|
|
}
|
|
|
|
@test "a failed update keeps the installed binary" {
|
|
write_conf 1.0 "$SHA"
|
|
bash "$REPO/install-binaries.sh"
|
|
write_conf 2.0 0000000000000000000000000000000000000000000000000000000000000000
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 1 ]
|
|
[ "$(cat "$HOME/.local/bin/tool")" = "v1" ]
|
|
grep -qx "tool=1.0" "$HAMPACK_STATE/.installed_versions"
|
|
}
|
|
|
|
@test "update with nothing new downloads nothing but refreshes the desktop file" {
|
|
write_conf 1.0 "$SHA"
|
|
bash "$REPO/install-binaries.sh"
|
|
rm "$SRC/tool" "$HOME/.local/share/applications/tool.desktop"
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"up to date"* ]]
|
|
[ -f "$HOME/.local/share/applications/tool.desktop" ]
|
|
}
|
|
|
|
@test "update with a new version downloads it" {
|
|
write_conf 1.0 "$SHA"
|
|
bash "$REPO/install-binaries.sh"
|
|
echo "v2" > "$SRC/tool"
|
|
write_conf 2.0 "$(sha256sum "$SRC/tool" | cut -d' ' -f1)"
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ "$(cat "$HOME/.local/bin/tool")" = "v2" ]
|
|
grep -qx "tool=2.0" "$HAMPACK_STATE/.installed_versions"
|
|
}
|
|
|
|
@test "an installed binary with no recorded version is reinstalled" {
|
|
write_conf 1.0 "$SHA"
|
|
echo stale > "$HOME/.local/bin/tool"
|
|
run bash "$REPO/install-binaries.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ "$(cat "$HOME/.local/bin/tool")" = "v1" ]
|
|
}
|