From bacf7a94d9ac886b098b909719135ece1e059e37 Mon Sep 17 00:00:00 2001
From: "samuel.trahan" <Samuel.Trahan@noaa.gov>
Date: Sat, 6 Jul 2024 00:16:52 +0000
Subject: [PATCH] bug fix to failed test detection with rocoto

---
 tests/rt_utils.sh | 3 +++
 tests/run_test.sh | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/rt_utils.sh b/tests/rt_utils.sh
index 6881fbf75a..a8aba0860d 100755
--- a/tests/rt_utils.sh
+++ b/tests/rt_utils.sh
@@ -380,6 +380,9 @@ check_results() {
 
   if [[ ${test_status} = 'FAIL' ]]; then
     echo "${TEST_ID} failed in check_result" >> "${PATHRT}/fail_test_${TEST_ID}"
+    return 1
+  else
+    return 0
   fi
 }
 
diff --git a/tests/run_test.sh b/tests/run_test.sh
index d3125fb83f..a9091ce15e 100755
--- a/tests/run_test.sh
+++ b/tests/run_test.sh
@@ -405,8 +405,11 @@ else
 
 fi
 skip_check_results=${skip_check_results:-false}
+results_okay=YES
 if [[ ${skip_check_results} = false ]]; then
-  check_results
+  if ( ! check_results ) ; then
+    results_okay=NO
+  fi
 else
   {
   echo
@@ -422,7 +425,7 @@ if [[ ${SCHEDULER} != 'none' ]]; then
   cat "${RUNDIR}/job_timestamp.txt" >> "${LOG_DIR}/${JBNME}_timestamp.txt"
 fi
 
-if [[ ${ROCOTO} = true ]]; then
+if [[ ${results_okay} == YES ]]; then
   remove_fail_test
 fi