2019-04-19 15:31:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# this has to run once atfer git clone
|
|
|
|
# and every time we create new hooks
|
2020-12-13 17:07:27 +00:00
|
|
|
#### $$VERSION$$ v1.2-dev2-11-ga25f876
|
2019-04-19 15:31:01 +00:00
|
|
|
|
|
|
|
# magic to ensure that we're always inside the root of our application,
|
|
|
|
# no matter from which directory we'll run script
|
2019-05-11 10:07:06 +00:00
|
|
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
|
|
|
if [ "$GIT_DIR" != "" ] ; then
|
|
|
|
cd "$GIT_DIR/.." || exit 1
|
|
|
|
else
|
|
|
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
|
|
|
fi
|
2019-04-19 15:31:01 +00:00
|
|
|
|
|
|
|
# create test environment
|
|
|
|
TESTENV="/tmp/bashbot.test$$"
|
2019-04-22 08:19:16 +00:00
|
|
|
mkdir "${TESTENV}"
|
2019-04-22 18:34:43 +00:00
|
|
|
cp -r ./* "${TESTENV}"
|
2019-04-20 19:09:36 +00:00
|
|
|
cd "test" || exit 1
|
2019-04-20 14:26:16 +00:00
|
|
|
|
2020-12-04 20:35:21 +00:00
|
|
|
# delete possible config
|
2020-12-13 17:07:27 +00:00
|
|
|
rm -f "${TESTENV}/botconfig.jssh" "${TESTENV}/botacl" 2>/dev/null
|
2020-12-04 20:35:21 +00:00
|
|
|
|
2019-04-19 15:31:01 +00:00
|
|
|
#set -e
|
|
|
|
fail=0
|
|
|
|
tests=0
|
|
|
|
passed=0
|
|
|
|
#all_tests=${__dirname:}
|
|
|
|
#echo PLAN ${#all_tests}
|
2019-04-22 18:34:43 +00:00
|
|
|
for test in $(find ./*-test.sh | sort -u) ;
|
2019-04-19 15:31:01 +00:00
|
|
|
do
|
2020-09-06 16:56:13 +00:00
|
|
|
[ "${test}" = "dev/all-tests.sh" ] && continue
|
2019-04-19 15:31:01 +00:00
|
|
|
[ ! -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
|
2020-08-05 05:41:49 +00:00
|
|
|
rm -rf "${TESTENV}"
|
2019-04-19 15:31:01 +00:00
|
|
|
else
|
|
|
|
/bin/echo -n 'FAILURE '
|
|
|
|
exitcode=1
|
2020-08-05 05:41:49 +00:00
|
|
|
rm -rf "${TESTENV}/test"
|
|
|
|
find "${TESTENV}/"* ! -name '[a-z]-*' -delete
|
2019-04-19 15:31:01 +00:00
|
|
|
fi
|
|
|
|
|
2019-04-26 15:19:48 +00:00
|
|
|
echo -e "${passed} / ${tests}\\n"
|
2019-04-22 08:19:16 +00:00
|
|
|
[ -d "${TESTENV}" ] && echo "Logfiles from run are in ${TESTENV}"
|
2019-04-26 13:07:07 +00:00
|
|
|
|
2020-09-06 16:56:13 +00:00
|
|
|
ls -ld /tmp/bashbot.test* 2>/dev/null && echo "Do not forget to delete bashbot test files in /tmp!!"
|
2019-04-26 13:07:07 +00:00
|
|
|
|
2019-04-19 15:31:01 +00:00
|
|
|
exit ${exitcode}
|