<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9404">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pretty_print: Fix pass/fail parsing and column width<br><br>Fixed the parsing ot the test result line so it accepts both old and<br>new style results.<br><br>Fixed calculation of column width when there is no TERM. It now<br>defaults to 80 if the --term-width argument wasn't specified.<br><br>Now setting -no-color and --no-timer if TERM isn't set.<br><br>Change-Id: I7dc1d02f43ca1c115821e0096159585ab6dcd43e<br>---<br>M contrib/scripts/pretty_print<br>1 file changed, 21 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/contrib/scripts/pretty_print b/contrib/scripts/pretty_print</span><br><span>index 8ee22d8..b50f87d 100755</span><br><span>--- a/contrib/scripts/pretty_print</span><br><span>+++ b/contrib/scripts/pretty_print</span><br><span>@@ -27,9 +27,11 @@</span><br><span> </span><br><span> SHOW_ERRORS=0</span><br><span> VERBOSE=0</span><br><span style="color: hsl(0, 100%, 40%);">-TERM_WIDTH=$(tput cols)</span><br><span> NO_COLOR=0</span><br><span> NO_TIMER=0</span><br><span style="color: hsl(120, 100%, 40%);">+TERM_WIDTH=0</span><br><span style="color: hsl(120, 100%, 40%);">+declare -ix test_timeout=0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> for a in "$@" ; do</span><br><span> OPTION_COUNT+=1</span><br><span> case "$a" in</span><br><span>@@ -51,7 +53,16 @@</span><br><span> esac</span><br><span> done</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-declare -ix test_timeout=0</span><br><span style="color: hsl(120, 100%, 40%);">+if [ x"$TERM" = x ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ NO_TIMER=1</span><br><span style="color: hsl(120, 100%, 40%);">+ NO_COLOR=1</span><br><span style="color: hsl(120, 100%, 40%);">+ if [ $TERM_WIDTH -le 0 ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ TERM_WIDTH=80</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ TERM_WIDTH=$(tput cols)</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> </span><br><span> if [ $NO_COLOR -gt 0 ] ; then</span><br><span> YELLOW=''</span><br><span>@@ -87,7 +98,7 @@</span><br><span> done</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-echo -e -n "Calculating...\r"</span><br><span style="color: hsl(120, 100%, 40%);">+echo -e "Calculating..."</span><br><span> declare -i run=0</span><br><span> declare -i runs=0</span><br><span> declare -ix runnable=0</span><br><span>@@ -120,9 +131,9 @@</span><br><span> if [[ $run -eq 1 && $line =~ ^Tests\ to\ run:\ +([0-9]+)\ +\*\ +([0-9]+)\ +time\(s\)\ +=\ +([0-9]+)\ +Maximum.test.inactivity.time:.([-0-9-]+) ]] ; then</span><br><span> runnable=$(( ${BASH_REMATCH[1]} * $runs ))</span><br><span> export test_timeout=${BASH_REMATCH[4]}</span><br><span style="color: hsl(0, 100%, 40%);">- printf "=%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo</span><br><span style="color: hsl(120, 100%, 40%);">+ printf "=%.0s" $(seq 1 ${TERM_WIDTH}) ; echo</span><br><span> echo "${line/-1/unlimited}"</span><br><span style="color: hsl(0, 100%, 40%);">- col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))</span><br><span style="color: hsl(120, 100%, 40%);">+ col=$(( ${TERM_WIDTH} - ${#status_string} ))</span><br><span> printf "%-*.*s[%-12s][%s][${GREEN}%4s${NORM}][${RED}%4s${NORM}]\n" $col $col "Test" " Test" "Status" "Pass" "Fail"</span><br><span> fi</span><br><span> </span><br><span>@@ -130,7 +141,7 @@</span><br><span> unset buffer</span><br><span> declare -a buffer</span><br><span> (( tests++ ))</span><br><span style="color: hsl(0, 100%, 40%);">- col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} -1 ))</span><br><span style="color: hsl(120, 100%, 40%);">+ col=$(( ${TERM_WIDTH} - ${#status_string} -1 ))</span><br><span> testname=${BASH_REMATCH[1]#*/}</span><br><span> tnl=$(( ${#testname} - $col ))</span><br><span> [ $tnl -le 0 ] && tnl=0</span><br><span>@@ -145,11 +156,11 @@</span><br><span> fi</span><br><span> fi</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if [[ $line =~ ^Test\ *\[(\'[^\']+\',)?\ *\'tests/([^\']+)\'(, \'[^\']+\')?\]\ *(passed|failed|timed\ out)$ ]] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ if [[ $line =~ ^Test\ *(\[\'[^\']+\',\ \')?tests/([^\' ]+)(\', \'[^\']+\'\])?\ *(passed|failed|timed\ out)$ ]] ; then</span><br><span> test=${BASH_REMATCH[2]}</span><br><span> _unused_arg=${BASH_REMATCH[3]}</span><br><span> status=${BASH_REMATCH[4]}</span><br><span style="color: hsl(0, 100%, 40%);">- col=$(( ${TERM_WIDTH:-$(tput cols)} - ${#status_string} ))</span><br><span style="color: hsl(120, 100%, 40%);">+ col=$(( ${TERM_WIDTH} - ${#status_string} ))</span><br><span> et=$(( $SECONDS - $st ))</span><br><span> [ $countpid -gt 0 ] && kill $countpid</span><br><span> show=0</span><br><span>@@ -198,9 +209,9 @@</span><br><span> </span><br><span> elapsed=$(( $SECONDS - $starttime ))</span><br><span> time="$(( $elapsed / 60 ))m $(( $elapsed % 60 ))s"</span><br><span style="color: hsl(0, 100%, 40%);">-printf "+%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo</span><br><span style="color: hsl(120, 100%, 40%);">+printf "+%.0s" $(seq 1 ${TERM_WIDTH}) ; echo</span><br><span> echo -e "Tests: $runnable ${GREEN}Passed: $passed ${RED}Failed: $failed TimedOut: $timedout${NORM} Time: $time\tLongest test: ${maxelapsed}s"</span><br><span style="color: hsl(0, 100%, 40%);">-printf "=%.0s" $(seq 1 ${TERM_WIDTH:-$(tput cols)}) ; echo</span><br><span style="color: hsl(120, 100%, 40%);">+printf "=%.0s" $(seq 1 ${TERM_WIDTH}) ; echo</span><br><span> </span><br><span> trap - INT ERR</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9404">change 9404</a>. To unsubscribe, or for help writing mail filters, 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/9404"/><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: I7dc1d02f43ca1c115821e0096159585ab6dcd43e </div>
<div style="display:none"> Gerrit-Change-Number: 9404 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>