mo/run-tests
Tyler Akins 1c03949107 Enabling a "false is empty" style check.
This is based off of pull request #10 from @athieriot.
Thanks for the idea!  I've implemented it as a flag and an environment
variable that can be enabled.  I've also added another test to handle
the environment variable.
2016-07-27 09:56:33 -05:00

40 lines
759 B
Bash
Executable File

#!/usr/bin/env bash
cd "$(dirname $0)"
. ./mo
PASS=0
FAIL=0
for TEST in tests/*.expected; do
BASE="${TEST%.expected}"
MO_FALSE_IS_EMPTY=
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
. "${BASE}.env"
echo "Do not read this input" | mo "${BASE}.template"
fi
) | diff -wU5 - "${TEST}" > "${BASE}.diff"
if [[ $? -ne 0 ]]; then
echo "FAIL"
FAIL=$(( $FAIL + 1 ))
else
echo "ok"
PASS=$(( $PASS + 1 ))
rm "${BASE}.diff"
fi
done
echo ""
echo "Pass: $PASS"
echo "Fail: $FAIL"
[[ $FAIL -gt 0 ]] && exit 1