Add bats test suite

Black-box tests that run the script with stub commands on a minimal PATH and temp config/state folders.
This commit is contained in:
Daniele Fucini
2026-11-09 19:51:42 +01:00
parent 1328cd5eca
commit bd8ded486d
9 changed files with 456 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# "pacman -Q <pkg>": looks the package up in $STUB_DATA/installed ("name version" lines).
[[ ${1:-} == -Q && $# == 2 ]] || { echo "pacman stub: unsupported arguments: $*" >&2; exit 1; }
if [[ -f $STUB_DATA/installed ]]; then
while read -r name ver; do
if [[ $name == "$2" ]]; then
printf '%s %s\n' "$name" "$ver"
exit 0
fi
done < "$STUB_DATA/installed"
fi
printf "error: package '%s' was not found\n" "$2" >&2
exit 1