Skip to content
Browse files

Added the new test script.

  • Loading branch information...
1 parent 14c87da commit 31de4b50bcdde47c8d417d4bbcc19d0cd016de5f @SaltwaterC committed Mar 26, 2012
Showing with 28 additions and 6 deletions.
  1. +28 −6 tools/test.sh
View
34 tools/test.sh
@@ -1,23 +1,45 @@
-#!/bin/sh
+#!/usr/bin/env bash
-NODE_BIN='/usr/bin/env node'
+NODE_BIN="/usr/bin/env node"
FAIL=0
+SUCCESS=0
TOTAL=0
cd tests
-for TEST in `ls ./*.js`
+for TEST in $(ls ./*.js)
do
if [ -f $TEST ]
then
- echo "Running test: "`basename $TEST`
+ TOTAL=$(($TOTAL + 1))
+ fi
+done
+
+CURRENT=1
+for TEST in $(ls ./*.js)
+do
+ if [ -f $TEST ]
+ then
+ TEST_FILE=$(basename $TEST)
+ PERCENT=$(echo "$CURRENT / $TOTAL * 100" | bc -l | awk '{printf("%d\n",$1 + 0.5)}')
+ OUTPUT="\r[$PERCENT% | $CURRENT/$TOTAL | + $SUCCESS | - $FAIL] $TEST_FILE"
+ echo -ne $OUTPUT
$NODE_BIN $TEST > /dev/null
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]
then
- FAIL=$(($FAIL+1))
+ echo -e "\nFailed: $TEST_FILE"
+ FAIL=$(($FAIL + 1))
+ else
+ SUCCESS=$(($SUCCESS+1))
fi
- TOTAL=$(($TOTAL+1))
+ SPACER=""
+ for IDX in $(seq 0 ${#OUTPUT})
+ do
+ SPACER=" $SPACER"
+ done
+ echo -ne "\r$SPACER"
+ CURRENT=$(($CURRENT + 1))
fi
done

0 comments on commit 31de4b5

Please sign in to comment.
Something went wrong with that request. Please try again.