mo/run-tests

46 lines
909 B
Plaintext
Raw Normal View History

2015-10-02 14:46:41 +00:00
#!/usr/bin/env bash
2015-01-23 17:43:08 +00:00
cd "${0%/*}" || exit 1
2015-01-23 17:43:08 +00:00
# shellcheck disable=SC1091
. ./mo
2015-01-23 17:43:08 +00:00
PASS=0
FAIL=0
for TEST in tests/*.expected; do
2016-08-03 15:19:43 +00:00
export BASE="${TEST%.expected}"
export MO_FALSE_IS_EMPTY=
2015-01-23 17:43:08 +00:00
echo -n "$BASE ... "
(
if [[ -f "${BASE}.sh" ]]; then
# Run a shell script if one exists
"${BASE}.sh"
else
# Fall back to using .env and .template
# shellcheck disable=SC1090
. "${BASE}.env"
echo "Do not read this input" | mo "${BASE}.template"
fi
) | diff -U5 - "${TEST}" > "${BASE}.diff"
2015-01-23 17:43:08 +00:00
statusCode=$?
if [[ $statusCode -ne 0 ]]; then
echo "FAIL (status code $statusCode)"
2016-08-03 15:19:43 +00:00
FAIL=$(( FAIL + 1 ))
2015-01-23 17:43:08 +00:00
else
echo "ok"
2016-08-03 15:19:43 +00:00
PASS=$(( PASS + 1 ))
2015-01-23 17:43:08 +00:00
rm "${BASE}.diff"
fi
done
echo ""
echo "Pass: $PASS"
echo "Fail: $FAIL"
if [[ $FAIL -gt 0 ]]; then
exit 1
fi