forked from tests-always-included/mo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests
executable file
·45 lines (37 loc) · 909 Bytes
/
run-tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
cd "${0%/*}" || exit 1
# shellcheck disable=SC1091
. ./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
# shellcheck disable=SC1090
. "${BASE}.env"
echo "Do not read this input" | mo "${BASE}.template"
fi
) | diff -U5 - "${TEST}" > "${BASE}.diff"
statusCode=$?
if [[ $statusCode -ne 0 ]]; then
echo "FAIL (status code $statusCode)"
FAIL=$(( FAIL + 1 ))
else
echo "ok"
PASS=$(( PASS + 1 ))
rm "${BASE}.diff"
fi
done
echo ""
echo "Pass: $PASS"
echo "Fail: $FAIL"
if [[ $FAIL -gt 0 ]]; then
exit 1
fi