Fix #2490 - Kill other processes when the test script is interrupted

This commit is contained in:
w0rp 2019-05-12 15:42:09 +01:00
parent df90725c85
commit 3303f596e5
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
1 changed files with 24 additions and 0 deletions

View File

@ -140,6 +140,30 @@ trap '{ rm -rf "$output_dir"; }' EXIT
file_number=0
pid_list=''
# Used for killing tests when you kill the script.
cancel_tests() {
set +e
if [ -n "$pid_list" ]; then
for pid in $pid_list; do
kill "$pid"
wait "$pid"
done
fi
# shellcheck disable=SC2046
docker kill $(docker ps -a -q --filter ancestor="$image" --format='{{.ID}}') &> /dev/null
if [ -d "$output_dir" ]; then
rm -rf "$output_dir"
fi
echo
exit 1
}
trap cancel_tests INT TERM
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-v8.1 ]] && ((run_vim_81_tests)) ) \