fix(scripts): make example tests more shell compatible (#106)
This commit is contained in:
parent
114ff4d29f
commit
1304cf5f02
|
@ -1,22 +1,20 @@
|
||||||
#! /bin/bash
|
|
||||||
|
|
||||||
EXAMPLES="$(find ./examples -name '*.yml')"
|
EXAMPLES="$(find ./examples -name '*.yml')"
|
||||||
|
|
||||||
while read -r example;
|
for example in ${EXAMPLES};
|
||||||
do
|
do
|
||||||
echo "Testing: ${example}"
|
echo "Testing: ${example}"
|
||||||
|
|
||||||
USE_RULES="$(grep '# test rules' "${example}" | sed 's/# test rules \(.*\)/\1/')"
|
USE_RULES="$(grep '# test rules' "${example}" | sed 's/# test rules \(.*\)/\1/')"
|
||||||
[[ -z "${USE_RULES}" ]] && echo "Test example must have '# test rules' pragma" && exit 1
|
[ -z "${USE_RULES}" ] && echo "Test example must have '# test rules' pragma" && exit 1
|
||||||
|
|
||||||
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
|
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
|
||||||
[[ -z "${USE_TAGS}" ]] && echo "Test example must have '# test tags' pragma" && exit 1
|
[ -z "${USE_TAGS}" ] && echo "Test example must have '# test tags' pragma" && exit 1
|
||||||
|
|
||||||
EXPECTED_ERRORS="$(grep '# test error-count' "${example}" | sed 's/# test error-count \([0-9]*\)/\1/')"
|
EXPECTED_ERRORS="$(grep '# test error-count' "${example}" | sed 's/# test error-count \([0-9]*\)/\1/')"
|
||||||
[[ -z "${EXPECTED_ERRORS}" ]] && EXPECTED_ERRORS=0
|
[ -z "${EXPECTED_ERRORS}" ] && EXPECTED_ERRORS=0
|
||||||
|
|
||||||
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
|
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
|
||||||
[[ -z "${EXPECTED_STATUS}" ]] && EXPECTED_STATUS=0
|
[ -z "${EXPECTED_STATUS}" ] && EXPECTED_STATUS=0
|
||||||
|
|
||||||
echo "Using rules: ${USE_RULES}"
|
echo "Using rules: ${USE_RULES}"
|
||||||
echo "Using tags: ${USE_TAGS}"
|
echo "Using tags: ${USE_TAGS}"
|
||||||
|
@ -32,11 +30,11 @@ do
|
||||||
|
|
||||||
ACTUAL_STATUS=$?
|
ACTUAL_STATUS=$?
|
||||||
|
|
||||||
if [[ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ]];
|
if [ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ];
|
||||||
then
|
then
|
||||||
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
|
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done <<< "${EXAMPLES}"
|
done
|
||||||
|
|
||||||
echo "All examples passed."
|
echo "All examples passed."
|
||||||
|
|
Loading…
Reference in New Issue