summaryrefslogtreecommitdiff
path: root/run-tests
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-05-12 15:42:09 +0100
committerw0rp <devw0rp@gmail.com>2019-05-12 15:42:09 +0100
commit3303f596e504eec3b8b4202a7cfee4feff660699 (patch)
tree363d8dc86498bde5ba7a95b5ed849130347207c2 /run-tests
parentdf90725c858103f1c63eb1c96f3e4e4727c32a7d (diff)
downloadale-3303f596e504eec3b8b4202a7cfee4feff660699.zip
Fix #2490 - Kill other processes when the test script is interrupted
Diffstat (limited to 'run-tests')
-rwxr-xr-xrun-tests24
1 files changed, 24 insertions, 0 deletions
diff --git a/run-tests b/run-tests
index 06fa3547..53be0673 100755
--- a/run-tests
+++ b/run-tests
@@ -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)) ) \