Black-box tests that run the script with stub commands on a minimal PATH and temp config/state folders.
14 lines
477 B
Bash
Executable File
14 lines
477 B
Bash
Executable File
#!/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
|