[Asterisk-code-review] pretty print: Add options to show individual test output (testsuite[master])
George Joseph
asteriskteam at digium.com
Thu Aug 10 11:15:35 CDT 2017
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/6217
Change subject: pretty_print: Add options to show individual test output
......................................................................
pretty_print: Add options to show individual test output
--show-errors will show the test output if a test errors or
times out.
--verbose will show the test output regardless of status.
--plain will not use escape sequences to set colors.
--term-width=n will force the output to 'n' columns regardless of
actual terminal width.
Change-Id: I4a407214d4a16f460efc27c73a76498ec158d386
---
M contrib/scripts/pretty_print
1 file changed, 53 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/17/6217/1
diff --git a/contrib/scripts/pretty_print b/contrib/scripts/pretty_print
index 5544652..5c35cf6 100755
--- a/contrib/scripts/pretty_print
+++ b/contrib/scripts/pretty_print
@@ -13,11 +13,42 @@
exit 1
fi
+SHOW_ERRORS=0
+VERBOSE=0
+TERM_WIDTH=$(tput cols)
+PLAIN=0
+for a in "$@" ; do
+ OPTION_COUNT+=1
+ case "$a" in
+ --*=*)
+ [[ $a =~ --([^=]+)=(.*) ]]
+ l=${BASH_REMATCH[1]//-/_}
+ r=${BASH_REMATCH[2]}
+ eval ${l^^}=$r
+ ;;
+ --*)
+ [[ $a =~ --(.+) ]]
+ l=${BASH_REMATCH[1]//-/_}
+ eval ${l^^}=1
+ ;;
+ esac
+done
+
declare -ix test_timeout=0
+
+if [ $PLAIN -gt 0 ] ; then
+YELLOW=''
+GREEN=''
+RED=''
+BOLD=''
+NORM=''
+else
YELLOW='\033[01;33m'
GREEN='\033[01;32m'
RED='\033[01;31m'
+BOLD='\033[1m'
NORM='\033[m'
+fi
status_string="[nnnn of nnnn][Status][Pass][Fail]"
@@ -54,8 +85,13 @@
declare testname=""
starttime=$SECONDS
+unset buffer
+declare -a buffer
+
trap 'kill $countpid &>/dev/null' INT ERR
while read line ; do
+ buffer+=("$line")
+
### Running tests for Asterisk GIT-master-99dea9b (run 1 of 1)...
if [[ $line =~ ^Running\ tests\ for\ (Asterisk\ +[^\ ]+)\ +\(run\ +([0-9]+)\ +of\ +([0-9]+)\)\.\.\. ]] ; then
run=${BASH_REMATCH[2]}
@@ -68,18 +104,20 @@
export test_timeout=${BASH_REMATCH[4]}
echo ===========================================================================================
echo "${line/-1/unlimited}"
- col=$(( $(tput cols) - ${#status_string} ))
+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))
printf "%-*.*s[%-12s][%s][${GREEN}%4s${NORM}][${RED}%4s${NORM}]\n" $col $col "Test" " Test" "Status" "Pass" "Fail"
fi
if [[ $line =~ ^--\>.Running.test.\'(.+)\'.\.\.\. ]] ; then
+ unset buffer
+ declare -a buffer
(( tests++ ))
- col=$(( $(tput cols) - ${#status_string} -1 ))
+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} -1 ))
testname=${BASH_REMATCH[1]#*/}
tnl=$(( ${#testname} - $col ))
[ $tnl -le 0 ] && tnl=0
testname=${testname:$tnl}
- printf "%-*.*s [%4d of %4d]" $col $col ${testname} $tests $runnable
+ printf "${BOLD}%-*.*s${NORM} [%4d of %4d]" $col $col ${testname} $tests $runnable
st=$SECONDS
counter &
disown $!
@@ -89,15 +127,17 @@
if [[ $line =~ ^Test.*tests/([^\']+)\',.*(passed|failed|timed\ out)$ ]] ; then
test=${BASH_REMATCH[1]}
status=${BASH_REMATCH[2]}
- col=$(( $(tput cols) - ${#status_string} ))
+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))
et=$(( $SECONDS - $st ))
kill $countpid
+ show=0
if [[ $status = passed ]] ; then
(( passed++ ))
COLOR=${GREEN}
label=Passed
[[ $et -gt $maxelapsed ]] && maxelapsed=$et
+ [ $VERBOSE -gt 0 ] && show=1
fi
if [[ $status = failed ]] ; then
(( failed++ ))
@@ -105,6 +145,7 @@
label=Failed
failures+=("FAILED: $test")
[[ $et -gt $maxelapsed ]] && maxelapsed=$et
+ [ $SHOW_ERRORS -gt 0 -o $VERBOSE -gt 0 ] && show=1
fi
if [[ $status = "timed out" ]] ; then
(( failed++ ))
@@ -112,8 +153,16 @@
COLOR=${RED}
label=Hung!!
timeouts+=("TIMEDOUT: $test")
+ [ $SHOW_ERRORS -gt 0 -o $VERBOSE -gt 0 ] && show=1
fi
printf "[${COLOR}%s${NORM}][${GREEN}%4d${NORM}][${RED}%4d${NORM}]\n" $label $passed $failed
+ if [ $show -gt 0 ] ; then
+ echo ---------------------------------------------------------------------
+ printf "%s\n" "${buffer[@]}"
+ echo ---------------------------------------------------------------------
+ fi
+ unset buffer
+ declare -a buffer
fi
done
--
To view, visit https://gerrit.asterisk.org/6217
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a407214d4a16f460efc27c73a76498ec158d386
Gerrit-Change-Number: 6217
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170810/f8fd18a3/attachment.html>
More information about the asterisk-code-review
mailing list