telegram-bot-bash/dev/all-tests.sh
Kay Marquardt (Gnadelwartz) 81c8b041ec better handling of moved files
2019-04-26 11:28:51 +02:00

55 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.70-dev2-27-g2da31c1
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
GIT_DIR=$(git rev-parse --git-dir)
cd "${GIT_DIR}/.." || exit 1
# create test environment
TESTENV="/tmp/bashbot.test$$"
mkdir "${TESTENV}"
cp -r ./* "${TESTENV}"
cd "test" || exit 1
#set -e
fail=0
tests=0
passed=0
#all_tests=${__dirname:}
#echo PLAN ${#all_tests}
for test in $(find ./*-test.sh | sort -u) ;
do
[ "${test}" = "test/all-tests.sh" ] && continue
[ ! -x "${test}" ] && continue
tests=$((tests+1))
echo "TEST: ${test}"
"${test}" "${TESTENV}"
ret=$?
if [ "$ret" -eq 0 ] ; then
echo "OK: ---- ${test}"
passed=$((passed+1))
else
echo "FAIL: $test $fail"
fail=$((fail+ret))
break
fi
done
if [ "$fail" -eq 0 ]; then
/bin/echo -n 'SUCCESS '
exitcode=0
rm -rf "${TESTENV}"
else
/bin/echo -n 'FAILURE '
exitcode=1
rm -rf "${TESTENV}/test"
find "${TESTENV}/"* ! -name '[a-z]-*' -delete
fi
echo "${passed} / ${tests}"
[ -d "${TESTENV}" ] && echo "Logfiles from run are in ${TESTENV}"
exit ${exitcode}