| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# This is a basic test runner for shell script tests |
| 6 |
# it just searches for all test_ scripts under the tests |
| 7 |
# folder, and run them. |
| 8 |
|
| 9 |
GREEN="\033[1;32m" |
| 10 |
RED="\033[1;31m" |
| 11 |
NO_COL="\033[0m" |
| 12 |
|
| 13 |
echo "Running shell script unit tests..." |
| 14 |
|
| 15 |
CURDIR=$(pwd) |
| 16 |
SUCCESS=yes |
| 17 |
CNT=0 |
| 18 |
for i in $(find tests -type f -iname 'test_*') ; do |
| 19 |
DIRNAME=$(dirname $i) |
| 20 |
BASENAME=$(basename $i) |
| 21 |
cd ${DIRNAME} |
| 22 |
echo -n $i" ... " |
| 23 |
if ./${BASENAME} ; then |
| 24 |
echo "${GREEN}OK${NO_COL}" |
| 25 |
else |
| 26 |
SUCCESS=no |
| 27 |
echo "${RED}FAILED${NO_COL}" |
| 28 |
fi |
| 29 |
cd ${CURDIR} |
| 30 |
CNT=$(( ${CNT} + 1 )) |
| 31 |
done |
| 32 |
|
| 33 |
if [ "${SUCCESS}" = "yes" ] ; then |
| 34 |
echo "${GREEN}Successfully ran ${CNT} tests :)${NO_COL}" |
| 35 |
exit 0 |
| 36 |
else |
| 37 |
echo "${RED}Failure while running unit tests :(${NO_COL}" |
| 38 |
exit 1 |
| 39 |
fi |