#!/usr/bin/env bash
PATH=$(npm bin):$PATH

export DIR=$(pwd)
totalTestCount=0
failedTestCount=0

for f in $( find . -name "test.sh" ); do
    ((totalTestCount++))
	cd $(dirname $f)
	chmod a+x ./test.sh
	bash ./test.sh > output.json
	output=$(json-diff output.json expected-output.json);
	if [ "$output" != " undefined" ] ; then
        ((failedTestCount++))
	    echo "Test failed: $(pwd)"
	    json-diff output.json expected-output.json
	fi
	rm output.json
	cd "${DIR}"
done


RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
if (( failedTestCount > 0 )) ; then
    echo -e "${RED}${failedTestCount} of ${totalTestCount} tests FAILED${NC}"
    exit 1
else
    echo -e "${GREEN}All ${totalTestCount} tests PASSED${NC}"
    exit 0
fi
#!/usr/bin/env bash
PATH=$(npm bin):$PATH

export DIR=$(pwd)
shouldFail=false

for f in $( find . -name "test.sh" ); do
	cd $(dirname $f)
	chmod a+x ./test.sh
	bash ./test.sh > output.json
	output=$(json-diff output.json expected-output.json);
	if [ "$output" != " undefined" ] ; then
	    shouldFail=true
	    echo "Test failed: $(pwd)"
	    json-diff output.json expected-output.json
	fi
	rm output.json
	cd "${DIR}"
done

if [ "$shouldFail" = true ] ; then
    echo "Tests failed due to errors"
    exit 1
fi
--- 
+++ 
@@ -2,15 +2,17 @@
 PATH=$(npm bin):$PATH
 
 export DIR=$(pwd)
-shouldFail=false
+totalTestCount=0
+failedTestCount=0
 
 for f in $( find . -name "test.sh" ); do
+    ((totalTestCount++))
 	cd $(dirname $f)
 	chmod a+x ./test.sh
 	bash ./test.sh > output.json
 	output=$(json-diff output.json expected-output.json);
 	if [ "$output" != " undefined" ] ; then
-	    shouldFail=true
+        ((failedTestCount++))
 	    echo "Test failed: $(pwd)"
 	    json-diff output.json expected-output.json
 	fi
@@ -18,7 +20,14 @@
 	cd "${DIR}"
 done
 
-if [ "$shouldFail" = true ] ; then
-    echo "Tests failed due to errors"
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m'
+if (( failedTestCount > 0 )) ; then
+    echo -e "${RED}${failedTestCount} of ${totalTestCount} tests FAILED${NC}"
     exit 1
+else
+    echo -e "${GREEN}All ${totalTestCount} tests PASSED${NC}"
+    exit 0
 fi
Test runner displays number of failing/succeeded tests
