ale/run-tests

111 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash -eu
# Author: w0rp <devw0rp@gmail.com>
#
# This script runs tests for the ALE project. The following options are
# accepted:
#
# -v Enable verbose output
# --neovim-only Run tests only for NeoVim
# --vim-only Run tests only for Vim
current_image_id=d5a1b5915b09
image=w0rp/ale
exit_code=0
tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
# These flags are forwarded to the script for running Vader tests.
verbose_flag=''
quiet_flag=''
run_neovim_tests=1
run_vim_tests=1
run_vint=1
run_custom_checks=1
while [ $# -ne 0 ]; do
case $1 in
-v)
verbose_flag='-v'
shift
;;
-q)
quiet_flag='-q'
shift
;;
--neovim-only)
run_vim_tests=0
run_vint=0
run_custom_checks=0
shift
;;
--vim-only)
run_neovim_tests=0
run_vint=0
run_custom_checks=0
shift
;;
--no-vint)
run_vint=0
shift
;;
--vint-only)
run_vim_tests=0
run_neovim_tests=0
run_custom_checks=0
shift
;;
--no-custom-checks)
run_custom_checks=0
shift
;;
--custom-checks-only)
run_vim_tests=0
run_neovim_tests=0
run_vint=0
shift
;;
--)
shift
break
;;
-?*)
echo "Invalid argument: $1" 1>&2
exit 1
;;
*)
break
;;
esac
done
# Allow tests to be passed as arguments.
if [ $# -ne 0 ]; then
# This doesn't perfectly handle work splitting, but none of our files
# have spaces in the names.
tests="$*"
fi
# Delete .swp files in the test directory, which cause Vim 8 to hang.
find test -name '*.swp' -delete
docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \
|| docker pull "$image"
for vim in $(docker run --rm "$image" ls /vim-build/bin | grep '^neovim\|^vim' ); do
if [[ $vim =~ ^neovim ]] && ((run_neovim_tests)); then
test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" || exit_code=$?
elif ((run_vim_tests)); then
test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" || exit_code=$?
fi
done
if ((run_vint)); then
test/script/run-vint || exit_code=$?
fi
if ((run_custom_checks)); then
test/script/custom-checks || exit_code=$?
fi
exit $exit_code