diff --git a/helpers/lib b/helpers/lib index 6bea6e4..9606716 100644 --- a/helpers/lib +++ b/helpers/lib @@ -46,7 +46,7 @@ function retry { fi local count=0 - until "$@"; do + until eval "$@"; do # Command failed, otherwise until would have skipped the loop # Store return code so it can be reported to the user diff --git a/init b/init index e514598..6a6fff4 100644 --- a/init +++ b/init @@ -24,6 +24,9 @@ for lib in helpers logging filehandling git k8s test-utils; do . "${BASH_LIB_DIR_RELATIVE}/${lib}/lib" done +# Export functions to subshells +eval "$(declare -F | sed -e 's/-f /-fx /')" + # Export the absolute path # shellcheck disable=SC2086 BASH_LIB_DIR="$(abs_path ${BASH_LIB_DIR_RELATIVE})" diff --git a/tests-for-this-repo/helpers.bats b/tests-for-this-repo/helpers.bats index bbea6f8..7750605 100644 --- a/tests-for-this-repo/helpers.bats +++ b/tests-for-this-repo/helpers.bats @@ -111,4 +111,8 @@ teardown(){ assert [ ! -e "${temp_dir}/appendfile" ] } - +@test "retry succeeds with compound statements" { + run retry 3 "true && date >> ${afile}" + assert_success + assert_equal $(wc -l <${afile}) 1 +}