changeset 1554:e6a4ed6fc873

Add color support for scripts/test.sh and new SKIP_HOST for tests expected to fail on non-toybox implementations.
author Rob Landley <rob@landley.net>
date Fri, 14 Nov 2014 16:44:00 -0600
parents 2423dd884182
children 1aef47e34485
files scripts/runtest.sh
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/runtest.sh	Fri Nov 14 15:53:17 2014 -0600
+++ b/scripts/runtest.sh	Fri Nov 14 16:44:00 2014 -0600
@@ -37,6 +37,17 @@
 
 # Check config to see if option is enabled, set SKIP if not.
 
+SHOWPASS=PASS
+SHOWFAIL=FAIL
+SHOWSKIP=SKIP
+
+if tty -s <&1
+then
+  SHOWPASS="$(echo -e "\033[1m\033[32m${SHOWPASS}\033[0m")"
+  SHOWFAIL="$(echo -e "\033[1m\033[31m${SHOWFAIL}\033[0m")"
+  SHOWSKIP="$(echo -e "\033[1m\033[33m${SHOWSKIP}\033[0m")"
+fi
+
 optional()
 {
   option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
@@ -64,9 +75,9 @@
 
   [ -n "$DEBUG" ] && set -x
 
-  if [ -n "$SKIP" ]
+  if [ -n "$SKIP" ] || ( [ -n "$SKIP_HOST" ] && [ -n "$TEST_HOST" ])
   then
-    [ ! -z "$VERBOSE" ] && echo "SKIPPED: $NAME"
+    [ ! -z "$VERBOSE" ] && echo "$SHOWSKIP: $NAME"
     return 0
   fi
 
@@ -79,15 +90,16 @@
   if [ $? -ne 0 ]
   then
     FAILCOUNT=$[$FAILCOUNT+1]
-    echo "FAIL: $NAME"
+    echo "$SHOWFAIL: $NAME"
     if [ -n "$VERBOSE" ]
     then
-      echo "echo '$5' | $2"
+      [ ! -z "$4" ] && echo "echo -ne \"$4\" > input"
+      echo "echo -ne '$5' | $2"
       diff -u expected actual
       [ "$VERBOSE" == fail ] && exit 1
     fi
   else
-    echo "PASS: $NAME"
+    echo "$SHOWPASS: $NAME"
   fi
   rm -f input expected actual