1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

Tests: change output format of run_tests script and add -q option

Putting PASSED/FAILED on the left makes it easier to scan the results
and simplifies the code.  Also put starts around the word "*FAILED*"
to make it more obvious.

Also add a -q option to throw away test output and only display the
summary (if -s is also specified).

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit c44b632b010b7d57007f3c8f294271c7e0217e0d)
This commit is contained in:
Martin Schwenke 2011-05-25 13:39:11 +10:00
parent eae91c959e
commit 8d2c726deb

View File

@ -19,8 +19,9 @@ EOF
with_summary=false
with_desc=false
quiet=false
temp=$(getopt -n "$prog" -o "xdhs" -l help -- "$@")
temp=$(getopt -n "$prog" -o "xdhqs" -l help -- "$@")
[ $? != 0 ] && usage
@ -30,12 +31,19 @@ while true ; do
case "$1" in
-x) set -x; shift ;;
-d) with_desc=true ; shift ;; # 4th line of output is description
-q) quiet=true ; shift ;;
-s) with_summary=true ; shift ;;
--) shift ; break ;;
*) usage ;;
esac
done
if $quiet ; then
show_progress() { cat >/dev/null ; }
else
show_progress() { cat ; }
fi
######################################################################
tests_total=0
@ -46,34 +54,40 @@ rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's
ww=$((rows - 7))
tf=$(mktemp)
sf=$(mktemp)
set -o pipefail
for f; do
[ -x $f ] || fail "test \"$f\" is not executable"
tests_total=$(($tests_total + 1))
ctdb_test_run "$f" | tee "$tf"
ctdb_test_run "$f" | tee "$tf" | show_progress
status=$?
if [ $status -eq 0 ] ; then
tests_passed=$(($tests_passed + 1))
t="PASSED"
else
t="FAILED"
if $with_summary ; then
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
echo "$t $f" >>"$sf"
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
cat "$sf"
echo
echo "${tests_passed}/${tests_total} tests passed"
fi
rm -f "$sf"
test_exit