2019-09-20 21:44:51 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-09-21 20:43:17 +00:00
|
|
|
source "${SCRIPT_DIR}/src/main.sh"
|
2019-09-20 21:44:51 +00:00
|
|
|
|
2019-09-23 11:56:15 +00:00
|
|
|
PASSED=0
|
|
|
|
FAILED=0
|
|
|
|
|
2019-09-20 21:44:51 +00:00
|
|
|
test::success() {
|
2019-09-23 11:56:15 +00:00
|
|
|
PASSED=$((PASSED+1))
|
2019-09-20 23:08:13 +00:00
|
|
|
echo "Test passed!"
|
2019-09-20 21:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::fail() {
|
2019-09-23 11:56:15 +00:00
|
|
|
FAILED=$((FAILED+1))
|
2019-09-20 23:08:13 +00:00
|
|
|
echo "Test failed..."
|
2019-09-23 11:56:15 +00:00
|
|
|
return
|
2019-09-21 22:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::run() {
|
2019-09-21 22:24:09 +00:00
|
|
|
echo
|
|
|
|
echo "-> $1"
|
|
|
|
shift
|
|
|
|
eval "$*" && test::success || test::fail
|
2019-09-23 11:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::finish() {
|
|
|
|
echo
|
|
|
|
if [ $FAILED -gt 0 ]; then
|
|
|
|
echo "${PASSED} tests passed but ${FAILED} failed... :("
|
|
|
|
exit "${FAILED}"
|
|
|
|
else
|
|
|
|
echo "All ${PASSED} tests passed! :)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|