tame/tamer/tests/run-tests

67 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/bin/bash
# Run all executable `test-*` tests.
set -euo pipefail
mypath=$(dirname "$0")
. "$mypath/../conf.sh"
warn-verbose-tracing() {
if tamer-flag parser-trace-stderr; then
cat <<EOM
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! parser-trace-stderr !!!!
!!!! is enabled; output !!!!
!!!! will be very verbose !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOM
fi
}
find-tests() {
find . -name 'test-*' -executable
}
main() {
warn-verbose-tracing
local -i count=0
local -i failn=0
local fail_names=
while read -r test; do
echo "$test"
sed 's/./-/g' <<< "$test"
((++count))
(time -p "$test") || {
echo "ERR (exit code $?)"
echo
((++failn))
fail_names="${fail_names:+$fail_names$'\n'} - $test failed"
continue
}
echo OK
echo
done < <(find-tests)
warn-verbose-tracing
if ((failn > 0)); then
printf 'There were %d test failure(s):\n%s\n' "$failn" "$fail_names"
echo -e '\e[31m'
fi
printf '%d tests, %d failed\n' "$count" "$failn"
echo -en '\e[0m'
[ "$failn" -eq 0 ]
}
main "$@"