diff options
| author | Menny Even Danan <menny@evendanan.net> | 2020-02-25 19:06:11 +0000 |
|---|---|---|
| committer | Menny Even Danan <menny@evendanan.net> | 2020-02-25 19:26:52 +0000 |
| commit | a98be1d9ede203b3a415f2b8d68005e8f4d63573 (patch) | |
| tree | 0e702ab00bac8bcca64ce931ee957c0df47eb5df /scripts | |
| parent | 2a91f81f70bff08459ba4fb5e5144f6477a40ac8 (diff) | |
| download | AnySoftKeyboard-a98be1d9ede203b3a415f2b8d68005e8f4d63573.tar.gz AnySoftKeyboard-a98be1d9ede203b3a415f2b8d68005e8f4d63573.tar.bz2 | |
Re-try tests if gradle worker crashed
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/retry-on-SIGSEGV.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/retry-on-SIGSEGV.sh b/scripts/retry-on-SIGSEGV.sh new file mode 100755 index 000000000..0f05c7e1d --- /dev/null +++ b/scripts/retry-on-SIGSEGV.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +retries=$1 +shift +IFS=',' read -r -a retry_exit_codes_array <<< "$1" +retry_exit_codes=" ${retry_exit_codes_array[*]} " +shift + +echo "Will retry '$*' for ${retries} when exit-codes are '${retry_exit_codes}':" +set +e +count=0 +EXIT_CODE=0 +pwd +"$@" +EXIT_CODE=$? +echo "EXIT_CODE is ${EXIT_CODE}" +while [[ "${retry_exit_codes}" =~ .*" ${EXIT_CODE} ".* ]]; do + count=$((count + 1)) + if [[ ${count} -lt ${retries} ]]; then + echo "************** Retry ${count}/${retries} exited ${EXIT_CODE}, retrying in ${count} seconds..." + ./gradlew --stop + sleep ${count} + "$@" + EXIT_CODE=$? + echo "EXIT_CODE is ${EXIT_CODE}" + else + echo "Retry ${count}/${retries} exited ${EXIT_CODE}, no more retries left." + fi +done + +exit ${EXIT_CODE}
\ No newline at end of file |
