summaryrefslogtreecommitdiff
path: root/test/script
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-12-01 18:06:09 +0000
committerw0rp <devw0rp@gmail.com>2017-12-01 18:06:09 +0000
commit6650c9a901ae35e76754a389ee1ae67b6dfb754f (patch)
tree482ec6da545fe26415e788190ee9d01e3fd7d780 /test/script
parent499c1542727c7e79302529f61ffb2bbaecb08b68 (diff)
downloadale-6650c9a901ae35e76754a389ee1ae67b6dfb754f.zip
Break up the rest of the test script code into smaller files
Diffstat (limited to 'test/script')
-rwxr-xr-xtest/script/custom-checks137
-rwxr-xr-xtest/script/custom-linting-rules95
-rwxr-xr-xtest/script/run-vader-tests7
-rwxr-xr-xtest/script/run-vint18
4 files changed, 173 insertions, 84 deletions
diff --git a/test/script/custom-checks b/test/script/custom-checks
index e2c906b3..791053d4 100755
--- a/test/script/custom-checks
+++ b/test/script/custom-checks
@@ -1,95 +1,68 @@
#!/bin/bash -eu
-# This Bash script implements custom sanity checks for scripts beyond what
-# Vint covers, which are easy to check with regex.
+exit_code=0
+image=w0rp/ale
+docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
-# A flag for automatically fixing some errors.
-FIX_ERRORS=0
-RETURN_CODE=0
+echo '========================================'
+echo 'Running custom linting rules'
+echo '========================================'
+echo 'Custom warnings/errors follow:'
+echo
-function print_help() {
- echo "Usage: ./custom-checks [--fix] [DIRECTORY]" 1>&2
- echo 1>&2
- echo " -h, --help Print this help text" 1>&2
- echo " --fix Automatically fix some errors" 1>&2
- exit 1
-}
+set -o pipefail
+docker run -a stdout "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
+set +o pipefail
+echo
-while [ $# -ne 0 ]; do
- case $1 in
- -h) ;& --help)
- print_help
- ;;
- --fix)
- FIX_ERRORS=1
- shift
- ;;
- --)
- shift
- break
- ;;
- -?*)
- echo "Invalid argument: $1" 1>&2
- exit 1
- ;;
- *)
- break
- ;;
- esac
-done
+echo '========================================'
+echo 'Checking for duplicate tags'
+echo '========================================'
+echo 'Duplicate tags follow:'
+echo
-if [ $# -eq 0 ] || [ -z "$1" ]; then
- print_help
-fi
+grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d || exit_code=$?
-shopt -s globstar
+echo '========================================'
+echo 'Checking for invalid tag references'
+echo '========================================'
+echo 'Invalid tag references tags follow:'
+echo
-directories=("$@")
+tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+'
-check_errors() {
- regex="$1"
- message="$2"
+# 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
- for directory in "${directories[@]}"; do
- while IFS= read -r match; do
- RETURN_CODE=1
- echo "$match $message"
- done < <(grep -n "$regex" "$directory"/**/*.vim \
- | grep -v 'no-custom-checks' \
- | grep -o '^[^:]\+:[0-9]\+' \
- | sed 's:^\./::')
- done
-}
+echo '========================================'
+echo 'diff README.md and doc/ale.txt tables'
+echo '========================================'
+echo 'Differences follow:'
+echo
-if (( FIX_ERRORS )); then
- for directory in "${directories[@]}"; do
- sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
- sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
- sed -i 's/==#/is#/g' "$directory"/**/*.vim
- sed -i 's/==?/is?/g' "$directory"/**/*.vim
- sed -i 's/!=#/isnot#/g' "$directory"/**/*.vim
- sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
- done
-fi
+test/script/check-supported-tools-tables || exit_code=$?
-check_errors \
- '^function.*) *$' \
- 'Function without abort keyword (See :help except-compat)'
-check_errors '^function[^!]' 'function without !'
-check_errors ' \+$' 'Trailing whitespace'
-check_errors '^ * end\?i\? *$' 'Write endif, not en, end, or endi'
-check_errors '^ [^ ]' 'Use four spaces, not two spaces'
-check_errors $'\t' 'Use four spaces, not tabs'
-# This check should prevent people from using a particular inconsistent name.
-check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead'
-check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
-check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
-check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
-check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead."
-check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
-check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
-check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
-check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
-check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
+echo '========================================'
+echo 'Look for badly aligned doc tags'
+echo '========================================'
+echo 'Badly aligned tags follow:'
+echo
-exit $RETURN_CODE
+# 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=$?
+
+exit $exit_code
diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules
new file mode 100755
index 00000000..ef6d792f
--- /dev/null
+++ b/test/script/custom-linting-rules
@@ -0,0 +1,95 @@
+#!/bin/bash -eu
+
+# This Bash script implements custom sanity checks for scripts beyond what
+# Vint covers, which are easy to check with regex.
+
+# A flag for automatically fixing some errors.
+FIX_ERRORS=0
+RETURN_CODE=0
+
+function print_help() {
+ echo "Usage: test/script/custom-linting-rules [--fix] [DIRECTORY]" 1>&2
+ echo 1>&2
+ echo " -h, --help Print this help text" 1>&2
+ echo " --fix Automatically fix some errors" 1>&2
+ exit 1
+}
+
+while [ $# -ne 0 ]; do
+ case $1 in
+ -h) ;& --help)
+ print_help
+ ;;
+ --fix)
+ FIX_ERRORS=1
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -?*)
+ echo "Invalid argument: $1" 1>&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ $# -eq 0 ] || [ -z "$1" ]; then
+ print_help
+fi
+
+shopt -s globstar
+
+directories=("$@")
+
+check_errors() {
+ regex="$1"
+ message="$2"
+
+ for directory in "${directories[@]}"; do
+ while IFS= read -r match; do
+ RETURN_CODE=1
+ echo "$match $message"
+ done < <(grep -n "$regex" "$directory"/**/*.vim \
+ | grep -v 'no-custom-checks' \
+ | grep -o '^[^:]\+:[0-9]\+' \
+ | sed 's:^\./::')
+ done
+}
+
+if (( FIX_ERRORS )); then
+ for directory in "${directories[@]}"; do
+ sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
+ sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
+ sed -i 's/==#/is#/g' "$directory"/**/*.vim
+ sed -i 's/==?/is?/g' "$directory"/**/*.vim
+ sed -i 's/!=#/isnot#/g' "$directory"/**/*.vim
+ sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
+ done
+fi
+
+check_errors \
+ '^function.*) *$' \
+ 'Function without abort keyword (See :help except-compat)'
+check_errors '^function[^!]' 'function without !'
+check_errors ' \+$' 'Trailing whitespace'
+check_errors '^ * end\?i\? *$' 'Write endif, not en, end, or endi'
+check_errors '^ [^ ]' 'Use four spaces, not two spaces'
+check_errors $'\t' 'Use four spaces, not tabs'
+# This check should prevent people from using a particular inconsistent name.
+check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead'
+check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
+check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
+check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
+check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead."
+check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
+check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
+check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
+check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
+check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
+
+exit $RETURN_CODE
diff --git a/test/script/run-vader-tests b/test/script/run-vader-tests
index d28e1987..d5daec29 100755
--- a/test/script/run-vader-tests
+++ b/test/script/run-vader-tests
@@ -7,6 +7,7 @@ green='\033[0;32m'
nc='\033[0m'
verbose=0
quiet=0
+exit_code=0
while [ $# -ne 0 ]; do
case $1 in
@@ -109,12 +110,14 @@ if [[ $vim =~ ^neovim ]]; then
set -o pipefail
docker run -it -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
"/vim-build/bin/$vim" -u test/vimrc \
- --headless "+Vader! $tests" | filter-vader-output | color-vader-output
+ --headless "+Vader! $tests" | filter-vader-output | color-vader-output || exit_code=$?
set +o pipefail
else
set -o pipefail
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
"/vim-build/bin/$vim" -u test/vimrc \
- "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output
+ "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
set +o pipefail
fi
+
+exit "$exit_code"
diff --git a/test/script/run-vint b/test/script/run-vint
new file mode 100755
index 00000000..e1140307
--- /dev/null
+++ b/test/script/run-vint
@@ -0,0 +1,18 @@
+#!/bin/bash -eu
+
+exit_code=0
+image=w0rp/ale
+docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
+
+echo '========================================'
+echo 'Running Vint to lint our code'
+echo '========================================'
+echo 'Vint warnings/errors follow:'
+echo
+
+set -o pipefail
+docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
+set +o pipefail
+echo
+
+exit $exit_code