Add an option to the script for running tests for only showing the tests which failed

This commit is contained in:
w0rp 2017-05-20 19:02:01 +01:00
parent 04e0dda17a
commit 0d797c203f
1 changed files with 40 additions and 12 deletions

View File

@ -19,6 +19,7 @@ EXIT=0
tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader' tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
verbose=0 verbose=0
quiet=0
run_neovim_tests=1 run_neovim_tests=1
run_vim_tests=1 run_vim_tests=1
run_vint=1 run_vint=1
@ -30,6 +31,10 @@ while [ $# -ne 0 ]; do
verbose=1 verbose=1
shift shift
;; ;;
-q)
quiet=1
shift
;;
--neovim-only) --neovim-only)
run_vim_tests=0 run_vim_tests=0
run_vint=0 run_vint=0
@ -65,21 +70,44 @@ fi
docker images -q w0rp/ale | grep "^$CURRENT_IMAGE_ID" > /dev/null \ docker images -q w0rp/ale | grep "^$CURRENT_IMAGE_ID" > /dev/null \
|| docker pull "$IMAGE" || docker pull "$IMAGE"
function color-vader-output() { function filter-vader-output() {
local vader_started=0 # When verbose mode is off, suppress output until Vader starts.
local start_output="$verbose"
local filtered_data=''
while read -r; do while read -r; do
if ((!verbose)); then if ((!start_output)); then
# When verbose mode is off, suppress output until Vader starts. if [[ "$REPLY" = *'Starting Vader:'* ]]; then
if ((!vader_started)); then start_output=1
if [[ "$REPLY" = *'Starting Vader:'* ]]; then else
vader_started=1 continue
else
continue
fi
fi fi
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
}
function color-vader-output() {
while read -r; do
if [[ "$REPLY" = *'[EXECUTE] (X)'* ]]; then if [[ "$REPLY" = *'[EXECUTE] (X)'* ]]; then
echo -en "$RED" echo -en "$RED"
elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then
@ -117,7 +145,7 @@ if ((run_neovim_tests)); then
set -o pipefail set -o pipefail
docker run -it -e VADER_OUTPUT_FILE=/dev/stderr "${DOCKER_FLAGS[@]}" \ docker run -it -e VADER_OUTPUT_FILE=/dev/stderr "${DOCKER_FLAGS[@]}" \
"/vim-build/bin/$vim" -u test/vimrc \ "/vim-build/bin/$vim" -u test/vimrc \
--headless "+Vader! $tests" | color-vader-output || EXIT=$? --headless "+Vader! $tests" | filter-vader-output | color-vader-output || EXIT=$?
set +o pipefail set +o pipefail
done done
@ -135,7 +163,7 @@ if ((run_vim_tests)); then
set -o pipefail set -o pipefail
docker run -a stderr "${DOCKER_FLAGS[@]}" \ docker run -a stderr "${DOCKER_FLAGS[@]}" \
"/vim-build/bin/$vim" -u test/vimrc \ "/vim-build/bin/$vim" -u test/vimrc \
"+Vader! $tests" 2>&1 | color-vader-output || EXIT=$? "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || EXIT=$?
set +o pipefail set +o pipefail
done done