summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2023-06-06 07:55:49 +0200
committercos <cos>2023-06-06 11:34:06 +0200
commit5aa95e208fa49e03d3d298bda7e8c599b8421a9c (patch)
treef7413535a9a51ab8b9a996fffe4a07447bf05830
parentb3de5d17796f25fefba941f520227910184646da (diff)
downloadale-5aa95e208fa49e03d3d298bda7e8c599b8421a9c.zip
Allow running tests without Docker
-rw-r--r--Dockerfile2
-rwxr-xr-xrun-tests96
-rwxr-xr-xtest/script/custom-checks70
-rwxr-xr-xtest/script/run-vader-tests19
-rwxr-xr-xtest/script/run-vint10
5 files changed, 140 insertions, 57 deletions
diff --git a/Dockerfile b/Dockerfile
index c7cc6e98..20aa2274 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,6 @@
ARG TESTBED_VIM_VERSION=24
+# https://hub.docker.com/r/testbed/vim/
FROM testbed/vim:${TESTBED_VIM_VERSION}
RUN install_vim -tag v8.0.0027 -build \
@@ -19,6 +20,7 @@ ENV PACKAGES="\
RUN apk --update add $PACKAGES && \
rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
+# https://pypi.org/project/vim-vint/
RUN pip install vim-vint==0.3.21
RUN git clone https://github.com/junegunn/vader.vim vader && \
diff --git a/run-tests b/run-tests
index a2b83bd2..92f93fe0 100755
--- a/run-tests
+++ b/run-tests
@@ -24,11 +24,14 @@ tests='test/*.vader test/*/*.vader test/*/*/*.vader'
# These flags are forwarded to the script for running Vader tests.
verbose_flag=''
quiet_flag=''
+docker_flag=''
run_neovim_02_tests=1
+run_neovim_07_tests=0
run_neovim_08_tests=1
run_vim_80_tests=1
run_vim_90_tests=1
run_linters=1
+use_docker=1
while [ $# -ne 0 ]; do
case $1 in
@@ -68,6 +71,10 @@ while [ $# -ne 0 ]; do
run_linters=0
shift
;;
+ --neovim-07-also)
+ run_neovim_07_tests=1
+ shift
+ ;;
--vim-only)
run_neovim_02_tests=0
run_neovim_08_tests=0
@@ -114,6 +121,7 @@ while [ $# -ne 0 ]; do
echo ' --build-image Run docker image build only.'
echo ' --neovim-only Run tests only for NeoVim'
echo ' --neovim-02-only Run tests only for NeoVim 0.2'
+ echo ' --neovim-07-only Run tests for NeoVim 0.7 (not in Docker)'
echo ' --neovim-08-only Run tests only for NeoVim 0.8'
echo ' --vim-only Run tests only for Vim'
echo ' --vim-80-only Run tests only for Vim 8.2'
@@ -121,9 +129,15 @@ while [ $# -ne 0 ]; do
echo ' --linters-only Run only Vint and custom checks'
echo ' --fast Run only the fastest Vim and custom checks'
echo ' --help Show this help text'
+ echo ' --no-docker Skip using Docker (unsupported)'
echo ' -- Stop parsing options after this'
exit 0
;;
+ --no-docker)
+ use_docker=0
+ docker_flag='--no-docker'
+ shift
+ ;;
--)
shift
break
@@ -153,10 +167,6 @@ find test -name '*.swp' -delete
set -eu
-# Check if docker un image is available locally
-has_image=$(docker images --quiet "${image}:${image_tag}" | wc -l)
-arch=$(docker info -f '{{ .Architecture }}')
-
download_image() {
if [[ $arch != x86_64 ]]; then
echo "Pre-built docker image is not available for architecture ${arch}"
@@ -166,33 +176,39 @@ download_image() {
docker pull "${image}:${image_tag}" &> /dev/null
}
-if [ "$has_image" -eq 0 ] && ! download_image; then
- echo "Building run image ${image}:${image_tag}"
+if [ "$use_docker" -eq 1 ]; then
+ # Check if docker un image is available locally
+ has_image=$(docker images --quiet "${image}:${image_tag}" | wc -l)
+ arch=$(docker info -f '{{ .Architecture }}')
- build_args=( --build-arg GIT_VERSION="$git_version" )
+ if [ "$has_image" -eq 0 ] && ! download_image; then
+ echo "Building run image ${image}:${image_tag}"
- if [[ $arch != x86_64 ]]; then
- echo "Building testbed/vim:24 for $arch"
- testbed_vim_ref=902917c4caa50db2f2e80009b839605602f9f014
- docker build -t "testbed/vim:$testbed_vim_ref" "https://github.com/Vimjas/vim-testbed.git#$testbed_vim_ref"
- build_args+=( --build-arg TESTBED_VIM_VERSION="$testbed_vim_ref" )
- fi
+ build_args=( --build-arg GIT_VERSION="$git_version" )
- docker build "${build_args[@]}" -t "${image}:${image_tag}" .
- docker tag "${image}:${image_tag}" "${image}:latest"
+ if [[ $arch != x86_64 ]]; then
+ echo "Building testbed/vim:24 for $arch"
+ testbed_vim_ref=902917c4caa50db2f2e80009b839605602f9f014
+ docker build -t "testbed/vim:$testbed_vim_ref" "https://github.com/Vimjas/vim-testbed.git#$testbed_vim_ref"
+ build_args+=( --build-arg TESTBED_VIM_VERSION="$testbed_vim_ref" )
+ fi
- if [[ -z "${DOCKER_HUB_USER:-}" || -z "${DOCKER_HUB_PASS:-}" ]]; then
- echo "Docker Hub credentials not set, skip push"
+ docker build "${build_args[@]}" -t "${image}:${image_tag}" .
+ docker tag "${image}:${image_tag}" "${image}:latest"
+
+ if [[ -z "${DOCKER_HUB_USER:-}" || -z "${DOCKER_HUB_PASS:-}" ]]; then
+ echo "Docker Hub credentials not set, skip push"
+ else
+ echo "Push ${image}:${image_tag} to Docker Hub"
+ echo "$DOCKER_HUB_PASS" | docker login -u "$DOCKER_HUB_USER" --password-stdin
+ docker push "${image}:${image_tag}"
+ fi
else
- echo "Push ${image}:${image_tag} to Docker Hub"
- echo "$DOCKER_HUB_PASS" | docker login -u "$DOCKER_HUB_USER" --password-stdin
- docker push "${image}:${image_tag}"
+ echo "Docker run image ${image}:${image_tag} ready"
fi
-else
- echo "Docker run image ${image}:${image_tag} ready"
-fi
-docker tag "${image}:${image_tag}" "${image}:latest"
+ docker tag "${image}:${image_tag}" "${image}:latest"
+fi
output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
@@ -202,6 +218,7 @@ file_number=0
pid_list=''
# Used for killing tests when you kill the script.
+# shellcheck disable=SC2317
cancel_tests() {
set +e
@@ -223,17 +240,30 @@ cancel_tests() {
exit 1
}
-trap cancel_tests INT TERM
+[ "$use_docker" -ne 1 ] || trap cancel_tests INT TERM
+
+available_vims() {
+ if [ "$use_docker" -eq 1 ]; then
+ docker run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim'
+ else
+ vim --version |
+ sed -n 's/^VIM - Vi IMproved \([0-9.]\+\).*/vim-v\1=vim/p' || :
+ nvim --version |
+ sed -n 's/^NVIM \(v[0-9]\+\.[0-9]\+\).*/neovim-\1=nvim/p' || :
+ fi
+}
-for vim in $(docker run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim' ); do
- if ( [[ $vim =~ ^vim-v8.0 ]] && ((run_vim_80_tests)) ) \
- || ( [[ $vim =~ ^vim-v9.0 ]] && ((run_vim_90_tests)) ) \
- || ( [[ $vim =~ ^neovim-v0.2 ]] && ((run_neovim_02_tests)) ) \
- || ( [[ $vim =~ ^neovim-v0.8 ]] && ((run_neovim_08_tests)) ); then
+for vim in $( available_vims ); do
+ if ( [[ "$vim" =~ ^vim-v8.0 ]] && ((run_vim_80_tests)) ) \
+ || ( [[ "$vim" =~ ^vim-v9.0 ]] && ((run_vim_90_tests)) ) \
+ || ( [[ "$vim" =~ ^neovim-v0.2 ]] && ((run_neovim_02_tests)) ) \
+ || ( [[ "$vim" =~ ^neovim-v0.7 ]] && ((run_neovim_07_tests)) ) \
+ || ( [[ "$vim" =~ ^neovim-v0.8 ]] && ((run_neovim_08_tests)) ) \
+ || ( [[ "$vim" =~ ^neovim-v0.8 ]] && ((run_neovim_08_tests)) ); then
echo "Starting Vim: $vim..."
file_number=$((file_number+1))
- test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" \
- > "$output_dir/$file_number" 2>&1 &
+ test/script/run-vader-tests $quiet_flag $verbose_flag $docker_flag \
+ "${vim#*=}" "$tests" > "$output_dir/$file_number" 2>&1 &
pid_list="$pid_list $!"
fi
done
@@ -241,7 +271,7 @@ done
if ((run_linters)); then
echo "Starting Vint..."
file_number=$((file_number+1))
- test/script/run-vint > "$output_dir/$file_number" 2>&1 &
+ test/script/run-vint $docker_flag > "$output_dir/$file_number" 2>&1 &
pid_list="$pid_list $!"
echo "Starting Custom checks..."
diff --git a/test/script/custom-checks b/test/script/custom-checks
index 83afb28c..31804634 100755
--- a/test/script/custom-checks
+++ b/test/script/custom-checks
@@ -3,6 +3,12 @@
set -e
set -u
+if [ "${1:-}" = '--no-docker' ]; then
+ use_docker=1
+else
+ use_docker=0
+fi
+
exit_code=0
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
@@ -12,9 +18,13 @@ echo '========================================'
echo 'Custom warnings/errors follow:'
echo
-set -o pipefail
-docker run "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
-set +o pipefail
+if [ "$use_docker" -eq 1 ]; then
+ set -o pipefail
+ docker run "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
+ set +o pipefail
+else
+ ./test/script/custom-linting-rules . || exit_code=$?
+fi
echo
echo '========================================'
@@ -24,9 +34,13 @@ echo 'Duplicate tags follow:'
echo
set -o pipefail
-docker run "${docker_flags[@]}" test/script/check-duplicate-tags . || exit_code=$?
-set +o pipefail
+if [ "$use_docker" -eq 1 ]; then
+ docker run "${docker_flags[@]}" test/script/check-duplicate-tags . || exit_code=$?
+else
+ ./test/script/check-duplicate-tags . || exit_code=$?
+fi
echo
+set +o pipefail
echo '========================================'
echo 'Checking for invalid tag references'
@@ -35,7 +49,11 @@ echo 'Invalid tag references tags follow:'
echo
set -o pipefail
-docker run "${docker_flags[@]}" test/script/check-tag-references || exit_code=$?
+if [ "$use_docker" -eq 1 ]; then
+ docker run "${docker_flags[@]}" test/script/check-tag-references || exit_code=$?
+else
+ ./test/script/check-tag-references || exit_code=$?
+fi
set +o pipefail
echo '========================================'
@@ -45,7 +63,11 @@ echo 'Differences follow:'
echo
set -o pipefail
-docker run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
+if [ "$use_docker" -eq 1 ]; then
+ docker run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
+else
+ ./test/script/check-supported-tools-tables || exit_code=$?
+fi
set +o pipefail
echo '========================================'
@@ -55,7 +77,11 @@ echo 'Badly aligned tags follow:'
echo
set -o pipefail
-docker run "${docker_flags[@]}" test/script/check-tag-alignment || exit_code=$?
+if [ "$use_docker" -eq 1 ]; then
+ docker run "${docker_flags[@]}" test/script/check-tag-alignment || exit_code=$?
+else
+ ./test/script/check-tag-alignment || exit_code=$?
+fi
set +o pipefail
echo '========================================'
@@ -64,17 +90,27 @@ echo '========================================'
echo
set -o pipefail
-docker run "${docker_flags[@]}" test/script/check-toc || exit_code=$?
+if [ "$use_docker" -eq 1 ]; then
+ docker run "${docker_flags[@]}" test/script/check-toc || exit_code=$?
+else
+ ./test/script/check-toc || exit_code=$?
+fi
set +o pipefail
-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=$?
+if [ "$use_docker" -eq 1 ]; then
+ 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=$?
+else
+ echo '========================================'
+ echo 'Skipping Python code check'
+ echo '========================================'
+ echo
+fi
echo
exit $exit_code
diff --git a/test/script/run-vader-tests b/test/script/run-vader-tests
index 584a05bb..e42546fc 100755
--- a/test/script/run-vader-tests
+++ b/test/script/run-vader-tests
@@ -9,6 +9,7 @@ green='\033[0;32m'
nc='\033[0m'
verbose=0
quiet=0
+use_docker=1
while [ $# -ne 0 ]; do
case $1 in
@@ -20,6 +21,10 @@ while [ $# -ne 0 ]; do
quiet=1
shift
;;
+ --no-docker)
+ use_docker=0
+ shift
+ ;;
--)
shift
break
@@ -147,10 +152,16 @@ while [ "$tries" -lt 5 ]; do
exit_code=0
set -o pipefail
- # shellcheck disable=SC2086
- docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
- "/vim-build/bin/$vim" -u test/vimrc ${headless} \
- "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
+ if [ "$use_docker" -eq 1 ]; then
+ # shellcheck disable=SC2086
+ docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
+ "/vim-build/bin/$vim" -u test/vimrc ${headless} \
+ "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
+ else
+ VADER_OUTPUT_FILE=/dev/stderr "$vim" --clean -u "${VIMRC:-test/vimrc}" \
+ ${headless} "+Vader! $tests" 2>&1 | filter-vader-output |
+ color-vader-output || exit_code=$?
+ fi
set +o pipefail
if [ -s "$run_file" ]; then
diff --git a/test/script/run-vint b/test/script/run-vint
index ce42ad41..b3afbee6 100755
--- a/test/script/run-vint
+++ b/test/script/run-vint
@@ -12,9 +12,13 @@ echo '========================================'
echo 'Vint warnings/errors follow:'
echo
-set -o pipefail
-docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
-set +o pipefail
+if [ "${1:-}" = '--no-docker' ]; then
+ vint -s .
+else
+ set -o pipefail
+ docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
+ set +o pipefail
+fi
echo
exit $exit_code