2019-07-01 13:14:18 +00:00
|
|
|
EXAMPLES="$(find ./examples -name '*.yml')"
|
2019-07-01 12:50:34 +00:00
|
|
|
|
2019-10-30 23:24:00 +00:00
|
|
|
for example in ${EXAMPLES};
|
2019-07-01 12:50:34 +00:00
|
|
|
do
|
2019-07-01 13:02:38 +00:00
|
|
|
echo "Testing: ${example}"
|
|
|
|
|
|
|
|
USE_RULES="$(grep '# test rules' "${example}" | sed 's/# test rules \(.*\)/\1/')"
|
2019-10-30 23:24:00 +00:00
|
|
|
[ -z "${USE_RULES}" ] && echo "Test example must have '# test rules' pragma" && exit 1
|
2019-07-01 13:02:38 +00:00
|
|
|
|
|
|
|
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
|
2019-10-30 23:24:00 +00:00
|
|
|
[ -z "${USE_TAGS}" ] && echo "Test example must have '# test tags' pragma" && exit 1
|
2019-07-01 13:02:38 +00:00
|
|
|
|
|
|
|
EXPECTED_ERRORS="$(grep '# test error-count' "${example}" | sed 's/# test error-count \([0-9]*\)/\1/')"
|
2019-10-30 23:24:00 +00:00
|
|
|
[ -z "${EXPECTED_ERRORS}" ] && EXPECTED_ERRORS=0
|
2019-07-01 13:02:38 +00:00
|
|
|
|
2019-07-01 12:50:34 +00:00
|
|
|
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
|
2019-10-30 23:24:00 +00:00
|
|
|
[ -z "${EXPECTED_STATUS}" ] && EXPECTED_STATUS=0
|
2019-07-01 12:50:34 +00:00
|
|
|
|
2019-07-01 13:02:38 +00:00
|
|
|
echo "Using rules: ${USE_RULES}"
|
|
|
|
echo "Using tags: ${USE_TAGS}"
|
|
|
|
echo "Expected errors: ${EXPECTED_ERRORS}"
|
|
|
|
echo "Expected status: ${EXPECTED_STATUS}"
|
2019-07-01 12:50:34 +00:00
|
|
|
|
2019-07-01 13:46:09 +00:00
|
|
|
node out/index.js \
|
|
|
|
--config-path ./docs \
|
|
|
|
--config-name config-stderr.yml \
|
|
|
|
--rules "rules/${USE_RULES}.yml" \
|
2019-07-02 13:42:48 +00:00
|
|
|
--tag "${USE_TAGS}" \
|
|
|
|
--source "${example}"
|
2019-07-01 12:50:34 +00:00
|
|
|
|
|
|
|
ACTUAL_STATUS=$?
|
|
|
|
|
2019-10-30 23:24:00 +00:00
|
|
|
if [ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ];
|
2019-07-01 12:50:34 +00:00
|
|
|
then
|
2019-07-01 13:02:38 +00:00
|
|
|
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
|
2019-07-01 12:50:34 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-30 23:24:00 +00:00
|
|
|
done
|
2019-07-01 13:46:09 +00:00
|
|
|
|
|
|
|
echo "All examples passed."
|