This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/script/custom-checks
Kevin Clark f72e60c12a Fix check-supported-tools-tables check
sed wasn't using -E, so '|' wasn't being handled properly. Seems likely
that's sed-implementation specific, so now it runs through docker's sed
to support portability.
2020-11-27 20:32:51 -08:00

82 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
set -u
exit_code=0
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
echo '========================================'
echo 'Running custom linting rules'
echo '========================================'
echo 'Custom warnings/errors follow:'
echo
set -o pipefail
docker run -a stdout "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
set +o pipefail
echo
echo '========================================'
echo 'Checking for duplicate tags'
echo '========================================'
echo 'Duplicate tags follow:'
echo
grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d || exit_code=$?
echo '========================================'
echo 'Checking for invalid tag references'
echo '========================================'
echo 'Invalid tag references tags follow:'
echo
tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+'
# Grep for tags and references, and complain if we find a reference without
# a tag for the reference. Only our tags will be included.
diff -u \
<(grep --exclude=tags -roh "\\*$tag_regex\\*" doc | sort -u | sed 's/*//g') \
<(grep --exclude=tags -roh "|$tag_regex|" doc | sort -u | sed 's/|//g') \
| grep '^+[^+]' && exit_code=1
echo '========================================'
echo 'diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables'
echo '========================================'
echo 'Differences follow:'
echo
set -o pipefail
docker run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
set +o pipefail
echo '========================================'
echo 'Look for badly aligned doc tags'
echo '========================================'
echo 'Badly aligned tags follow:'
echo
# Documentation tags need to be aligned to the right margin, so look for
# tags which aren't at the right margin.
grep ' \*[^*]\+\*$' doc/ -r \
| awk '{ sep = index($0, ":"); if (length(substr($0, sep + 1 )) < 79) { print } }' \
| grep . && exit_code=1
echo '========================================'
echo 'Look for table of contents issues'
echo '========================================'
echo
test/script/check-toc || exit_code=$?
echo '========================================'
echo 'Check Python code'
echo '========================================'
echo
docker run --rm -v "$PWD:/testplugin" "$DOCKER_RUN_IMAGE" \
python -W ignore -m unittest discover /testplugin/test/python \
|| exit_code=$?
echo
exit $exit_code