mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
0627cbbaf8
When testing #19 I found that the tests were mistakenly ignoring some whitespace changes. I've enabled whitespace checks and had to update the tests because my editor likes newlines at the end of files and removes whitespace at the end of lines. To make the test files easier to manage, I've modified some scenarios to still test for the feature but also work with the whitespace modifications that editors would perform.
40 lines
764 B
Bash
Executable File
40 lines
764 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
cd "${0%/*}"
|
|
|
|
. ./mo
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
for TEST in tests/*.expected; do
|
|
export BASE="${TEST%.expected}"
|
|
export 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 -U5 - "${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
|