OSDN Git Service

Usischev Yury pointed out that id shouldn't use exit() directly.
[android-x86/external-toybox.git] / scripts / runtest.sh
index 7f9e8b9..13b82f1 100644 (file)
@@ -43,9 +43,9 @@ 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")"
+  SHOWPASS="$(echo -e "\033[1;32m${SHOWPASS}\033[0m")"
+  SHOWFAIL="$(echo -e "\033[1;31m${SHOWFAIL}\033[0m")"
+  SHOWSKIP="$(echo -e "\033[1;33m${SHOWSKIP}\033[0m")"
 fi
 
 optional()
@@ -64,7 +64,7 @@ optional()
 
 testing()
 {
-  NAME="$1"
+  NAME="$CMDNAME $1"
   [ -z "$1" ] && NAME=$2
 
   if [ $# -ne 5 ]
@@ -83,23 +83,23 @@ testing()
 
   echo -ne "$3" > expected
   echo -ne "$4" > input
-  echo -ne "$5" | eval "$2" > actual
+  echo -ne "$5" | ${EVAL:-eval} "$2" > actual
   RETVAL=$?
 
   # Catch segfaults
   [ $RETVAL -gt 128 ] && [ $RETVAL -lt 255 ] &&
     echo "exited with signal (or returned $RETVAL)" >> actual
  
-  cmp expected actual > /dev/null 2>&1
-  if [ $? -ne 0 ]
+  DIFF="$(diff -au${NOSPACE:+b} expected actual)"
+  if [ ! -z "$DIFF" ]
   then
     FAILCOUNT=$[$FAILCOUNT+1]
     echo "$SHOWFAIL: $NAME"
     if [ -n "$VERBOSE" ]
     then
       [ ! -z "$4" ] && echo "echo -ne \"$4\" > input"
-      echo "echo -ne '$5' | $2"
-      diff -au expected actual
+      echo "echo -ne '$5' |$EVAL $2"
+      echo "$DIFF"
       [ "$VERBOSE" == fail ] && exit 1
     fi
   else