1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00

tests/builtins.sh: correctly count errors (re: 1bc2c74c)

This commit is contained in:
Martijn Dekker 2020-09-12 03:24:22 +02:00
parent ddaa145b3d
commit 2ae6e2cf55

View file

@ -938,14 +938,20 @@ EOF
# ==========
# Builtins should handle unrecognized options correctly
(
builtin $(builtin -l | awk -F "/" '/\/opt/ {print $5}') # Load all /opt/ast/bin builtins
for name in $(builtin -l | grep -Ev '(echo|/opt|test|true|false|getconf|uname|\[|:)'); do
actual=$({ "$name" --this-option-does-not-exist; } 2>&1)
expect="Usage: $name"
[[ $actual =~ $expect ]] || err_exit "$name should show usage info on unrecognized options (expected $(printf '%q' "$expect"), got $(printf '%q' "$actual"))"
done
)
while IFS= read -r bltin <&3
do case $bltin in
echo | test | true | false | \[ | : | getconf | */getconf | uname | */uname)
continue ;;
/*/*) expect="Usage: ${bltin##*/} "
actual=$({ PATH=${bltin%/*}; "${bltin##*/}" --this-option-does-not-exist; } 2>&1) ;;
*/*) err_exit "strange path name in 'builtin' output: $(printf %q "$bltin")"
continue ;;
*) expect="Usage: $bltin "
actual=$({ "${bltin}" --this-option-does-not-exist; } 2>&1) ;;
esac
[[ $actual == *"$expect"* ]] || err_exit "$bltin should show usage info on unrecognized options" \
"(expected string containing $(printf %q "$expect"), got $(printf %q "$actual"))"
done 3< <(builtin)
# ======
exit $((Errors<125?Errors:125))