diff --git a/.gitlab-ci/setup-test-env.sh b/.gitlab-ci/setup-test-env.sh index f1c06039d81..a123201110d 100644 --- a/.gitlab-ci/setup-test-env.sh +++ b/.gitlab-ci/setup-test-env.sh @@ -34,24 +34,6 @@ function get_current_minsec { printf "%02d:%02d" $((CURR_TIME/60)) $((CURR_TIME%60)) } -function error { - x_off 2>/dev/null - RED="\e[0;31m" - ENDCOLOR="\e[0m" - # we force the following to be not in a section - if [ -n "${CURRENT_SECTION:-}" ]; then - _section_end $CURRENT_SECTION - fi - - CURR_MINSEC=$(get_current_minsec) - echo -e "\n${RED}[${CURR_MINSEC}] ERROR: $*${ENDCOLOR}\n" - x_restore -} - -function trap_err { - error ${CURRENT_SECTION:-'unknown-section'}: ret code: $* -} - function _build_section_start { local section_params=$1 shift @@ -116,8 +98,6 @@ export -f _x_store_state export -f _x_off export -f _x_restore export -f get_current_minsec -export -f error -export -f trap_err export -f _build_section_start export -f _section_start export -f _build_section_end @@ -136,5 +116,26 @@ if [ -z "${RESULTS_DIR:-}" ]; then mkdir -p "${RESULTS_DIR}" fi +function error { + x_off 2>/dev/null + RED="\e[0;31m" + ENDCOLOR="\e[0m" + # we force the following to be not in a section + if [ -n "${CURRENT_SECTION:-}" ]; then + _section_end $CURRENT_SECTION + fi + + CURR_MINSEC=$(get_current_minsec) + echo -e "\n${RED}[${CURR_MINSEC}] ERROR: $*${ENDCOLOR}\n" + x_restore +} + +function trap_err { + error ${CURRENT_SECTION:-'unknown-section'}: ret code: $* +} + +export -f error +export -f trap_err + set -E trap 'trap_err $?' ERR