From 3a8ef10e09837455f9feb85c8ad72f02b95a1cf2 Mon Sep 17 00:00:00 2001 From: YUNSHEN XIE <1084314248@qq.com> Date: Thu, 4 Mar 2021 17:02:09 +0800 Subject: [PATCH] fix modified_retry_method_only_win (#31404) * fix modified_retry_method_only_win * fix bug * fix retry bug on windows --- tools/windows/run_unittests.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/windows/run_unittests.sh b/tools/windows/run_unittests.sh index 409ea4dbdee..6365423d8a3 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 -- GitLab