[asterisk-commits] gtjoseph: testsuite/asterisk/trunk r4732 - /asterisk/trunk/contrib/scripts/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 24 10:39:04 CST 2014


Author: gtjoseph
Date: Mon Feb 24 10:39:02 2014
New Revision: 4732

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4732
Log:
testsuite:  Add pretty_print script to contrib/scripts

pretty_print filters the output of runtests.py down to 1 line
per test with pass/fail and running stats.  A summary is also
printed at test run completion recapping the failed tests.

Run the script with no options to see usage hints.


Added:
    asterisk/trunk/contrib/scripts/pretty_print   (with props)

Added: asterisk/trunk/contrib/scripts/pretty_print
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/contrib/scripts/pretty_print?view=auto&rev=4732
==============================================================================
--- asterisk/trunk/contrib/scripts/pretty_print (added)
+++ asterisk/trunk/contrib/scripts/pretty_print Mon Feb 24 10:39:02 2014
@@ -1,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2014, Fairview 5 Engineering, LLC
+# George Joseph <george.joseph at fairview5.com>
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License Version 2.
+#
+if [ -t 0 ] ; then
+	echo "pretty_print is a filter and needs the output of runtests.py piped to it."
+	echo "Try python -u ./runtests.py <options> | ./pretty_print"
+	echo "The 'python -u' is needed to use unbuffered output mode otherwise you'll only see output in big chunks."
+	exit 1
+fi
+
+declare -ix passed=0
+declare -ix failed=0
+declare -ix tests=0
+declare -a failures
+GREEN='\033[01;32m'
+RED='\033[01;31m'
+NORM='\033[m'
+
+col=$(( $(tput cols) - 28 ))
+
+trap break INT
+while read line ; do
+	if [[ $line =~ ^Running\ tests\ for.* ]] ; then
+		echo $line
+		printf "%-*.*s %4s/${GREEN}%4s${NORM}/${RED}%4s${NORM} ${COLOR} [ %s ]${NORM}\n" $col $col "Test" "Run" "Pass" "Fail" "Status"
+	fi
+	if [[ $line =~ ^Test.*(tests[^\']+)\',.*(passed|failed)$ ]] ; then
+		test=${BASH_REMATCH[1]}
+		status=${BASH_REMATCH[2]}
+		col=$(( $(tput cols) - 28 ))
+		(( tests++ ))
+		if [[ $status = passed ]] ; then
+			(( passed++ ))
+			COLOR=${GREEN}
+			label=Passed
+		fi
+		if [[ $status = failed ]] ; then
+			(( failed++ ))
+			COLOR=${RED}
+			label=Failed
+			failures+=("FAILED: $test")
+		fi
+		printf "%-*.*s %4d/${GREEN}%4d${NORM}/${RED}%4d${NORM} ${COLOR} [ %s ]${NORM}\n" $col $col $test $tests $passed $failed $label
+	fi
+done
+trap - INT
+echo -e "\tTests: $tests\t\t${GREEN}Passed: $passed\t\t${RED}Failed: $failed${NORM}"
+for fail in "${failures[@]}" ; do
+	echo -e "${RED}$fail${NORM}"
+done
+

Propchange: asterisk/trunk/contrib/scripts/pretty_print
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/contrib/scripts/pretty_print
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/contrib/scripts/pretty_print
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/contrib/scripts/pretty_print
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list