2018-05-01 12:18:03 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
2017-12-01 17:50:19 +00:00
|
|
|
|
2018-06-28 12:53:49 +00:00
|
|
|
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
|
2017-12-01 17:50:19 +00:00
|
|
|
red='\033[0;31m'
|
|
|
|
green='\033[0;32m'
|
|
|
|
nc='\033[0m'
|
|
|
|
verbose=0
|
|
|
|
quiet=0
|
|
|
|
|
|
|
|
while [ $# -ne 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
-v)
|
|
|
|
verbose=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-q)
|
|
|
|
quiet=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
-?*)
|
|
|
|
echo "Invalid argument: $1" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
vim="$1"
|
|
|
|
tests="$2"
|
2022-04-01 12:17:15 +00:00
|
|
|
|
|
|
|
echo "$vim"
|
|
|
|
|
|
|
|
case $vim in
|
|
|
|
neovim-v0.2*)
|
|
|
|
headless=''
|
|
|
|
;;
|
|
|
|
# Neovim 0.6+ requires headless argument to load Vader tests.
|
|
|
|
neovim*)
|
|
|
|
headless='--headless'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
headless=''
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-07-03 19:50:56 +00:00
|
|
|
# This file will be used to track if tests ran or not.
|
|
|
|
# We can't use a variable, because we need to set a value in a sub-shell.
|
|
|
|
run_file="$(mktemp -t tests_ran.XXXXXXXX)"
|
2017-12-01 17:50:19 +00:00
|
|
|
|
|
|
|
function filter-vader-output() {
|
2018-07-03 19:50:56 +00:00
|
|
|
local hit_first_vader_line=0
|
2017-12-01 17:50:19 +00:00
|
|
|
# When verbose mode is off, suppress output until Vader starts.
|
|
|
|
local start_output="$verbose"
|
|
|
|
local filtered_data=''
|
|
|
|
|
|
|
|
while read -r; do
|
2018-07-03 19:50:56 +00:00
|
|
|
# Search for the first Vader output line.
|
|
|
|
# We can try starting tests again if they don't start.
|
|
|
|
if ((!hit_first_vader_line)); then
|
2017-12-01 17:50:19 +00:00
|
|
|
if [[ "$REPLY" = *'Starting Vader:'* ]]; then
|
2018-07-03 19:50:56 +00:00
|
|
|
hit_first_vader_line=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ((!start_output)); then
|
|
|
|
if ((hit_first_vader_line)); then
|
2017-12-01 17:50:19 +00:00
|
|
|
start_output=1
|
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ((quiet)); then
|
|
|
|
if [[ "$REPLY" = *'Starting Vader:'* ]]; then
|
|
|
|
filtered_data="$REPLY"
|
|
|
|
elif [[ "$REPLY" = *'Success/Total'* ]]; then
|
|
|
|
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
|
|
|
|
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
|
|
|
|
|
|
|
|
if [ "$success" -lt "$total" ]; then
|
|
|
|
echo "$filtered_data"
|
|
|
|
echo "$REPLY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
filtered_data=''
|
|
|
|
else
|
|
|
|
filtered_data="$filtered_data"$'\n'"$REPLY"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "$REPLY"
|
|
|
|
fi
|
|
|
|
done
|
2018-07-03 19:50:56 +00:00
|
|
|
|
|
|
|
# Note that we managed to get the Vader tests started if we did.
|
|
|
|
if ((hit_first_vader_line)); then
|
|
|
|
echo 1 > "$run_file"
|
|
|
|
fi
|
2017-12-01 17:50:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function color-vader-output() {
|
|
|
|
while read -r; do
|
|
|
|
if [[ "$REPLY" = *'[EXECUTE] (X)'* ]]; then
|
|
|
|
echo -en "$red"
|
|
|
|
elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then
|
|
|
|
echo -en "$nc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$REPLY" = *'Success/Total'* ]]; then
|
|
|
|
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
|
|
|
|
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
|
|
|
|
|
|
|
|
if [ "$success" -lt "$total" ]; then
|
|
|
|
echo -en "$red"
|
|
|
|
else
|
|
|
|
echo -en "$green"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$REPLY"
|
|
|
|
echo -en "$nc"
|
|
|
|
else
|
|
|
|
echo "$REPLY"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -en "$nc"
|
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo '========================================'
|
|
|
|
echo "Running tests for $vim"
|
|
|
|
echo '========================================'
|
|
|
|
echo
|
|
|
|
|
2018-07-03 19:50:56 +00:00
|
|
|
tries=0
|
|
|
|
|
2018-07-12 13:02:38 +00:00
|
|
|
while [ "$tries" -lt 5 ]; do
|
2018-07-03 19:50:56 +00:00
|
|
|
tries=$((tries + 1))
|
|
|
|
|
|
|
|
exit_code=0
|
|
|
|
set -o pipefail
|
|
|
|
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
|
2022-04-01 12:17:15 +00:00
|
|
|
"/vim-build/bin/$vim" -u test/vimrc ${headless} \
|
2018-07-03 19:50:56 +00:00
|
|
|
"+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
|
|
|
|
set +o pipefail
|
|
|
|
|
|
|
|
if [ -s "$run_file" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$tries" -gt 1 ]; then
|
|
|
|
echo
|
|
|
|
echo "Tried to run tests $tries times"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm "$run_file"
|
2017-12-01 18:06:09 +00:00
|
|
|
|
|
|
|
exit "$exit_code"
|