mirror of
https://github.com/tests-always-included/mo.git
synced 2025-04-09 18:21:15 +00:00
Move loop over tests to separate file
This commit is contained in:
parent
343135760c
commit
ed2ab8f2a6
33
run-basic-tests
Executable file
33
run-basic-tests
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
|
||||
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
|
30
run-tests
30
run-tests
@ -7,35 +7,7 @@ cd "$(dirname "$0")" || exit 1
|
||||
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
|
||||
source ./run-basic-tests
|
||||
|
||||
echo ""
|
||||
echo "Pass: $PASS"
|
||||
|
Loading…
x
Reference in New Issue
Block a user