This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 30c97d66579 Fix error propagation in new tests (#44087)
30c97d66579 is described below

commit 30c97d6657939ec6ceddef0edaddd08c55024b7d
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Nov 16 11:17:43 2024 +0100

    Fix error propagation in new tests (#44087)
    
    The #43979 introduced unit_tests.sh script that did not properly
    propagate error codes (no -e/+e setting).
    
    This PR fixes it - also fixes an edge case where the -e setting
    is not restored in run breeze commmand script.
---
 .../ci/testing/run_breeze_command_with_retries.sh  |  1 +
 scripts/ci/testing/run_unit_tests.sh               | 38 +++++++++++++++++++---
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/scripts/ci/testing/run_breeze_command_with_retries.sh 
b/scripts/ci/testing/run_breeze_command_with_retries.sh
index 0d4086b0962..7f2bb56785c 100755
--- a/scripts/ci/testing/run_breeze_command_with_retries.sh
+++ b/scripts/ci/testing/run_breeze_command_with_retries.sh
@@ -28,6 +28,7 @@ for i in $(seq 1 "$NUMBER_OF_ATTEMPT") ; do
     breeze down
     set +e
     if breeze "$@"; then
+        set -e
         exit 0
     else
         echo
diff --git a/scripts/ci/testing/run_unit_tests.sh 
b/scripts/ci/testing/run_unit_tests.sh
index 016f82bb757..8c250983cfe 100755
--- a/scripts/ci/testing/run_unit_tests.sh
+++ b/scripts/ci/testing/run_unit_tests.sh
@@ -31,68 +31,98 @@ TEST_SCOPE=${2}
 
 function core_tests() {
     echo "${COLOR_BLUE}Running core tests${COLOR_RESET}"
+    set +e
     if [[ "${TEST_SCOPE}" == "DB" ]]; then
         set -x
         breeze testing core-tests --run-in-parallel --run-db-tests-only
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "Non-DB" ]]; then
         set -x
         breeze testing core-tests --use-xdist --skip-db-tests --no-db-cleanup 
--backend none
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "All" ]]; then
         set -x
         breeze testing core-tests --run-in-parallel
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "Quarantined" ]]; then
         set -x
-        breeze testing core-tests --test-type "All-Quarantined"
+        breeze testing core-tests --test-type "All-Quarantined" || true
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "ARM collection" ]]; then
         set -x
         breeze testing core-tests --collect-only --remove-arm-packages 
--test-type "All"
+        RESULT=$?
         set +x
     elif [[  "${TEST_SCOPE}" == "System" ]]; then
         set -x
         breeze testing system-tests tests/system/example_empty.py
+        RESULT=$?
         set +x
     else
         echo "Unknown test scope: ${TEST_SCOPE}"
+        set -e
         exit 1
     fi
-    echo "${COLOR_BLUE}Core tests completed${COLOR_RESET}"
+    set -e
+    if [[ ${RESULT} != "0" ]]; then
+        echo
+        echo "${COLOR_RED}The ${TEST_GROUP} test ${TEST_SCOPE} failed! Giving 
up${COLOR_RESET}"
+        echo
+        exit "${RESULT}"
+    fi
+    echo "${COLOR_GREEN}Core tests completed successfully${COLOR_RESET}"
 }
 
 function providers_tests() {
     echo "${COLOR_BLUE}Running providers tests${COLOR_RESET}"
+    set +e
     if [[ "${TEST_SCOPE}" == "DB" ]]; then
         set -x
         breeze testing providers-tests --run-in-parallel --run-db-tests-only
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "Non-DB" ]]; then
         set -x
         breeze testing providers-tests --use-xdist --skip-db-tests 
--no-db-cleanup --backend none
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "All" ]]; then
         set -x
         breeze testing providers-tests --run-in-parallel
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "Quarantined" ]]; then
         set -x
-        breeze testing providers-tests --test-type "All-Quarantined"
+        breeze testing providers-tests --test-type "All-Quarantined" || true
+        RESULT=$?
         set +x
     elif [[ "${TEST_SCOPE}" == "ARM collection" ]]; then
         set -x
         breeze testing providers-tests --collect-only --remove-arm-packages 
--test-type "All"
+        RESULT=$?
         set +x
     elif [[  "${TEST_SCOPE}" == "System" ]]; then
         set -x
         breeze testing system-tests providers/tests/system/example_empty.py
+        RESULT=$?
         set +x
     else
         echo "Unknown test scope: ${TEST_SCOPE}"
+        set -e
         exit 1
     fi
-    echo "${COLOR_BLUE}Providers tests completed${COLOR_RESET}"
+    set -e
+    if [[ ${RESULT} != "0" ]]; then
+        echo
+        echo "${COLOR_RED}The ${TEST_GROUP} test ${TEST_SCOPE} failed! Giving 
up${COLOR_RESET}"
+        echo
+        exit "${RESULT}"
+    fi
+    echo "${COLOR_GREEB}Providers tests completed successfully${COLOR_RESET}"
 }
 
 

Reply via email to