<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6217">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pretty_print: Add options to show individual test output<br><br>--show-errors: If a test fails, show the output.<br>--verbose: Regardless of test status, show the output.<br>--term-width=n: Force output to span 'n' columns.<br>--no-color: Don't use escape sequences to display color.<br>--no-timer: Don't display the timer as tests run.<br> Together, --no-color and --no-timer make the output<br> suitable for redirecting to a file.<br><br>Change-Id: I4a407214d4a16f460efc27c73a76498ec158d386<br>---<br>M contrib/scripts/pretty_print<br>1 file changed, 91 insertions(+), 21 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/contrib/scripts/pretty_print b/contrib/scripts/pretty_print<br>index 5544652..200b0b3 100755<br>--- a/contrib/scripts/pretty_print<br>+++ b/contrib/scripts/pretty_print<br>@@ -7,19 +7,67 @@<br> # the GNU General Public License Version 2.<br> #<br> <br>+print_help() {<br>+ echo "$1: Pretty print the output of runtests.py"<br>+ echo "runtests.py ... | $1 [ --show-errors ] [ --verbose ] [ --term_width=n ]"<br>+ echo " [ --no-color ] [ --no-timer ]"<br>+ echo " --show-errors: If a test fails, show the output."<br>+ echo " --verbose: Regardless of test status, show the output."<br>+ echo " --term-width=n: Force output to span 'n' columns."<br>+ echo " --no-color: Don't use escape sequences to display color."<br>+ echo " --no-timer: Don't display the timer as tests run."<br>+ echo " Together, --no-color and --no-timer make the output"<br>+ echo " suitable for redirecting to a file."<br>+}<br>+<br> if [ -t 0 ] ; then<br>- echo "pretty_print is a filter and needs the output of runtests.py piped to it."<br>- echo "Try ./runtests.py <options> | $0"<br>+ print_help $(basename $0)<br> exit 1<br> fi<br> <br>-declare -ix test_timeout=0<br>-YELLOW='\033[01;33m'<br>-GREEN='\033[01;32m'<br>-RED='\033[01;31m'<br>-NORM='\033[m'<br>+SHOW_ERRORS=0<br>+VERBOSE=0<br>+TERM_WIDTH=$(tput cols)<br>+NO_COLOR=0<br>+NO_TIMER=0<br>+for a in "$@" ; do<br>+ OPTION_COUNT+=1<br>+ case "$a" in<br>+ --*=*)<br>+ [[ $a =~ --([^=]+)=(.*) ]]<br>+ l=${BASH_REMATCH[1]//-/_}<br>+ r=${BASH_REMATCH[2]}<br>+ eval ${l^^}=$r<br>+ ;;<br>+ --*)<br>+ [[ $a =~ --(.+) ]]<br>+ l=${BASH_REMATCH[1]//-/_}<br>+ eval ${l^^}=1<br>+ ;;<br>+ *)<br>+ print_help $(basename $0)<br>+ exit 1<br>+ ;;<br>+ esac<br>+done<br> <br>-status_string="[nnnn of nnnn][Status][Pass][Fail]"<br>+declare -ix test_timeout=0<br>+<br>+if [ $NO_COLOR -gt 0 ] ; then<br>+ YELLOW=''<br>+ GREEN=''<br>+ RED=''<br>+ BOLD=''<br>+ NORM=''<br>+else<br>+ YELLOW='\033[01;33m'<br>+ GREEN='\033[01;32m'<br>+ RED='\033[01;31m'<br>+ BOLD='\033[1m'<br>+ NORM='\033[m'<br>+fi<br>+<br>+status_string="[nnnn of nnnn][Status][Pass][Fail] "<br> <br> counter() {<br> status=Running<br>@@ -35,7 +83,7 @@<br> else<br> printf "[%12s %3ss ]" "Running for" $et<br> fi<br>- tput cub 19<br>+ tput cub 20<br> done<br> }<br> <br>@@ -54,8 +102,14 @@<br> declare testname=""<br> starttime=$SECONDS<br> <br>+unset buffer<br>+declare -a buffer<br>+<br> trap 'kill $countpid &>/dev/null' INT ERR<br> while read line ; do<br>+ [ -z "$line" ] && continue<br>+ buffer+=("$line")<br>+<br> ### Running tests for Asterisk GIT-master-99dea9b (run 1 of 1)...<br> if [[ $line =~ ^Running\ tests\ for\ (Asterisk\ +[^\ ]+)\ +\(run\ +([0-9]+)\ +of\ +([0-9]+)\)\.\.\. ]] ; then<br> run=${BASH_REMATCH[2]}<br>@@ -66,38 +120,45 @@<br> if [[ $run -eq 1 && $line =~ ^Tests\ to\ run:\ +([0-9]+)\ +\*\ +([0-9]+)\ +time\(s\)\ +=\ +([0-9]+)\ +Maximum.test.inactivity.time:.([-0-9-]+) ]] ; then<br> runnable=$(( ${BASH_REMATCH[1]} * $runs ))<br> export test_timeout=${BASH_REMATCH[4]}<br>- echo ===========================================================================================<br>+ printf "=%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo<br> echo "${line/-1/unlimited}"<br>- col=$(( $(tput cols) - ${#status_string} ))<br>+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))<br> printf "%-*.*s[%-12s][%s][${GREEN}%4s${NORM}][${RED}%4s${NORM}]\n" $col $col "Test" " Test" "Status" "Pass" "Fail"<br> fi<br> <br> if [[ $line =~ ^--\>.Running.test.\'(.+)\'.\.\.\. ]] ; then<br>+ unset buffer<br>+ declare -a buffer<br> (( tests++ ))<br>- col=$(( $(tput cols) - ${#status_string} -1 ))<br>+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} -1 ))<br> testname=${BASH_REMATCH[1]#*/}<br> tnl=$(( ${#testname} - $col ))<br> [ $tnl -le 0 ] && tnl=0<br> testname=${testname:$tnl}<br>- printf "%-*.*s [%4d of %4d]" $col $col ${testname} $tests $runnable<br>+ printf "${BOLD}%-*.*s${NORM} [%4d of %4d]" $col $col ${testname} $tests $runnable<br> st=$SECONDS<br>- counter &<br>- disown $!<br>- countpid=$!<br>+ countpid=-1<br>+ if [ $NO_TIMER -eq 0 ] ; then<br>+ counter &<br>+ disown $!<br>+ countpid=$!<br>+ fi<br> fi<br> <br> if [[ $line =~ ^Test.*tests/([^\']+)\',.*(passed|failed|timed\ out)$ ]] ; then<br> test=${BASH_REMATCH[1]}<br> status=${BASH_REMATCH[2]}<br>- col=$(( $(tput cols) - ${#status_string} ))<br>+ col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))<br> et=$(( $SECONDS - $st ))<br>- kill $countpid<br>+ [ $countpid -gt 0 ] && kill $countpid<br>+ show=0<br> <br> if [[ $status = passed ]] ; then<br> (( passed++ ))<br> COLOR=${GREEN}<br> label=Passed<br> [[ $et -gt $maxelapsed ]] && maxelapsed=$et<br>+ [ $VERBOSE -gt 0 ] && show=1<br> fi<br> if [[ $status = failed ]] ; then<br> (( failed++ ))<br>@@ -105,6 +166,7 @@<br> label=Failed<br> failures+=("FAILED: $test")<br> [[ $et -gt $maxelapsed ]] && maxelapsed=$et<br>+ [ $SHOW_ERRORS -gt 0 -o $VERBOSE -gt 0 ] && show=1<br> fi<br> if [[ $status = "timed out" ]] ; then<br> (( failed++ ))<br>@@ -112,8 +174,16 @@<br> COLOR=${RED}<br> label=Hung!!<br> timeouts+=("TIMEDOUT: $test")<br>+ [ $SHOW_ERRORS -gt 0 -o $VERBOSE -gt 0 ] && show=1<br> fi<br> printf "[${COLOR}%s${NORM}][${GREEN}%4d${NORM}][${RED}%4d${NORM}]\n" $label $passed $failed<br>+ if [ $show -gt 0 ] ; then<br>+ echo ---------------------------------------------------------------------<br>+ printf "%s\n" "${buffer[@]}"<br>+ echo ---------------------------------------------------------------------<br>+ fi<br>+ unset buffer<br>+ declare -a buffer<br> fi<br> <br> done<br>@@ -127,10 +197,10 @@<br> <br> elapsed=$(( $SECONDS - $starttime ))<br> time="$(( $elapsed / 60 ))m $(( $elapsed % 60 ))s"<br>-echo -------------------------------------------------------------------------------------------<br>+printf "+%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo<br> echo -e "Tests: $runnable ${GREEN}Passed: $passed ${RED}Failed: $failed TimedOut: $timedout${NORM} Time: $time\tLongest test: ${maxelapsed}s"<br>-echo ===========================================================================================<br>+printf "=%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo<br> <br> trap - INT ERR<br> <br>-kill $countpid &>/dev/null<br>+[ $countpid -gt 0 ] && kill $countpid &>/dev/null<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6217">change 6217</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6217"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I4a407214d4a16f460efc27c73a76498ec158d386 </div>
<div style="display:none"> Gerrit-Change-Number: 6217 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>