diff options
| author | Martin Schwenke <martin@meltin.net> | 2011-05-23 15:41:59 +1000 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2011-08-03 15:51:44 +1000 |
| commit | eae91c959e487eb3513e98cbd5476d2107cd22f8 (patch) | |
| tree | 3cdc03e06b521dee2965c633b777b50c20d75385 | |
| parent | 82d59bbc8efc080dce7cf794e7ba6bda2aab1af0 (diff) | |
| download | samba-eae91c959e487eb3513e98cbd5476d2107cd22f8.tar.gz samba-eae91c959e487eb3513e98cbd5476d2107cd22f8.tar.xz samba-eae91c959e487eb3513e98cbd5476d2107cd22f8.zip | |
Test suite: add a -d option to the run_tests script.
This causes summary lines (when used with -s) to be pretty printed and
include the test description. This is the 4th line of the test output
- that is, immediately after the header.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 0e5cc2a58b0d38e10a2ef9e81dc887c20f3fbdcb)
| -rwxr-xr-x | ctdb/tests/scripts/run_tests | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ctdb/tests/scripts/run_tests b/ctdb/tests/scripts/run_tests index 8a87859352..5906c42814 100755 --- a/ctdb/tests/scripts/run_tests +++ b/ctdb/tests/scripts/run_tests @@ -18,8 +18,9 @@ EOF ###################################################################### with_summary=false +with_desc=false -temp=$(getopt -n "$prog" -o "xhs" -l help -- "$@") +temp=$(getopt -n "$prog" -o "xdhs" -l help -- "$@") [ $? != 0 ] && usage @@ -28,6 +29,7 @@ eval set -- "$temp" 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 ;; @@ -43,18 +45,31 @@ summary="" 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 |
