From 9dbcee4875c71afbaf0df42f8e5ce3b6533d6c14 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 14 Nov 2014 16:44:00 -0600 Subject: Add color support for scripts/test.sh and new SKIP_HOST for tests expected to fail on non-toybox implementations. --- scripts/runtest.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'scripts/runtest.sh') diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 08be6fa0..ce4dedf9 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -37,6 +37,17 @@ export SKIP= # 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 @@ testing() [ -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 @@ testing() 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 -- cgit v1.2.3