diff --git a/tools/windows/run_unittests.sh b/tools/windows/run_unittests.sh index 409ea4dbdeecc430a360dfd217b431835fb0677e..6365423d8a36098f0062d4e3c4da649219587b4a 100644 --- a/tools/windows/run_unittests.sh +++ b/tools/windows/run_unittests.sh @@ -221,6 +221,7 @@ non_parallel_job_2=$(echo $non_parallel_job | cut -d "," -f 2) failed_test_lists='' tmp_dir=`mktemp -d` function collect_failed_tests() { + set +e for file in `ls $tmp_dir`; do grep -q 'The following tests FAILED:' $tmp_dir/$file exit_code=$? @@ -232,6 +233,7 @@ function collect_failed_tests() { ${failuretest}" fi done + set -e } function run_unittest() { @@ -247,7 +249,7 @@ function run_unittest() { echo "************************************************************************" export CUDA_VISIBLE_DEVICES=0 tmpfile=$tmp_dir/$RANDOM - (ctest -R "$test_case" -E "$disable_ut_quickly|$diable_wingpu_test|$long_time_test" -LE "${nightly_label}" --output-on-failure -C Release -j $parallel_job --repeat until-pass:4 after-timeout:4 | tee $tmpfile ) & + (ctest -R "$test_case" -E "$disable_ut_quickly|$diable_wingpu_test|$long_time_test" -LE "${nightly_label}" --output-on-failure -C Release -j $parallel_job | tee $tmpfile ) & wait; } @@ -259,8 +261,9 @@ function unittests_retry(){ exec_times=0 exec_retry_threshold=10 retry_unittests=$(echo "${failed_test_lists}" | grep -oEi "\-.+\(" | sed 's/(//' | sed 's/- //' ) - need_retry_ut_counts=$(echo "$ut_lists" |awk -F ' ' '{print }'| sed '/^$/d' | wc -l) + need_retry_ut_counts=$(echo "$retry_unittests" |awk -F ' ' '{print }'| sed '/^$/d' | wc -l) retry_unittests_regular=$(echo "$retry_unittests" |awk -F ' ' '{print }' | awk 'BEGIN{ all_str=""}{if (all_str==""){all_str=$1}else{all_str=all_str"$|^"$1}} END{print "^"all_str"$"}') + tmpfile=$tmp_dir/$RANDOM if [ $need_retry_ut_counts -lt $exec_retry_threshold ];then retry_unittests_record='' @@ -271,7 +274,7 @@ function unittests_retry(){ cur_order='first' elif ( [[ "$exec_times" == "1" ]] );then cur_order='second' - elif ( [[ "$exec_times" == "1" ]] );then + elif ( [[ "$exec_times" == "2" ]] );then cur_order='third' fi echo "=========================================" @@ -282,7 +285,8 @@ function unittests_retry(){ echo "=========================================" rm -f $tmp_dir/* failed_test_lists='' - ctest -R "($retry_unittests_regular)" --output-on-failure -C Release -j $parallel_job| tee $tmpfile + (ctest -R "($retry_unittests_regular)" --output-on-failure -C Release -j $parallel_job| tee $tmpfile ) & + wait; collect_failed_tests exec_times=$(echo $exec_times | awk '{print $0+1}') done