######################################################################
with_summary=false
+with_desc=false
-temp=$(getopt -n "$prog" -o "xhs" -l help -- "$@")
+temp=$(getopt -n "$prog" -o "xdhs" -l help -- "$@")
[ $? != 0 ] && usage
while true ; do
case "$1" in
-x) set -x; shift ;;
+ -d) with_desc=true ; shift ;; # 4th line of output is description
-s) with_summary=true ; shift ;;
--) shift ; break ;;
*) usage ;;
rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's@^0$@80@')
ww=$((rows - 7))
+tf=$(mktemp)
+
+set -o pipefail
+
for f; do
[ -x $f ] || fail "test \"$f\" is not executable"
tests_total=$(($tests_total + 1))
- if ctdb_test_run "$f" ; then
+ ctdb_test_run "$f" | tee "$tf"
+ status=$?
+ if [ $status -eq 0 ] ; then
tests_passed=$(($tests_passed + 1))
t="PASSED"
else
t="FAILED"
fi
+ if $with_desc ; then
+ f="${f#./}" ; f="${f%%[./]*}"
+ desc=$(tail -n +4 $tf | head -n 1)
+ f="${f} ${desc}"
+ fi
summary=$(printf "%s\n%-${ww}s%s" "$summary" "$f" "$t")
done
+rm -f "$tf"
+
if $with_summary ; then
echo "$summary"
echo