Skip to content

Commit 9fd5eae

Browse files
authored
add failed unittests retry on mac system (#26813)
* add retry on mac * fix some error * fix with some errors
1 parent 92bf0d4 commit 9fd5eae

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

paddle/scripts/paddle_build.sh

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,17 +528,72 @@ EOF
528528
elif [ "$1" == "cp37-cp37m" ]; then
529529
pip3.7 install --user ${INSTALL_PREFIX:-/paddle/build}/opt/paddle/share/wheels/*.whl
530530
fi
531+
tmpfile_rand=`date +%s%N`
532+
tmpfile=$tmp_dir/$tmpfile_rand
531533
set +e
532534
ut_startTime_s=`date +%s`
533-
ctest --output-on-failure -j $2;mactest_error=$?
535+
ctest --output-on-failure -j $2 | tee $tmpfile
536+
failed_test_lists=''
537+
collect_failed_tests
538+
set +x
539+
mactest_error=0
540+
retry_unittests_record=''
541+
retry_time=3
542+
exec_times=0
543+
exec_time_array=('first' 'second' 'third')
544+
if [ -n "$failed_test_lists" ];then
545+
mactest_error=1
546+
while ( [ $exec_times -lt $retry_time ] && [ -n "${failed_test_lists}" ] )
547+
do
548+
retry_unittests_record="$retry_unittests_record$failed_test_lists"
549+
failed_test_lists_ult=`echo "${failed_test_lists}"`
550+
read retry_unittests <<< $(echo "$failed_test_lists" | grep -oEi "\-.+\(" | sed 's/(//' | sed 's/- //' )
551+
echo "========================================="
552+
echo "This is the ${exec_time_array[$exec_times]} time to re-run"
553+
echo "========================================="
554+
echo "The following unittest will be re-run:"
555+
echo "${retry_unittests}"
556+
echo "========================================="
557+
558+
retry_unittests_regular=''
559+
for line in ${retry_unittests[@]} ;
560+
do
561+
if [[ "$retry_unittests_regular" == "" ]];then
562+
retry_unittests_regular="^$line$"
563+
else
564+
retry_unittests_regular="$retry_unittests_regular|^$line$"
565+
fi
566+
done
567+
rm -f $tmp_dir/*
568+
failed_test_lists=''
569+
ctest -R "($retry_unittests_regular)" --output-on-failure -j $2 | tee $tmpfile
570+
collect_failed_tests
571+
exec_times=$[$exec_times+1]
572+
done
573+
fi
574+
#mactest_error=$?
534575
ut_endTime_s=`date +%s`
535576
echo "Mac testCase Time: $[ $ut_endTime_s - $ut_startTime_s ]s"
536577
paddle version
537578
# Recovery proxy to avoid failure in later steps
538579
export http_proxy=$my_proxy
539580
export https_proxy=$my_proxy
540581
if [ "$mactest_error" != 0 ];then
541-
exit 8;
582+
if [[ "$failed_test_lists" == "" ]]; then
583+
echo "========================================"
584+
echo "There are failed tests, which have been successful after re-run:"
585+
echo "========================================"
586+
echo "The following tests have been re-ran:"
587+
echo "${retry_unittests_record}"
588+
else
589+
failed_test_lists_ult=`echo "${failed_test_lists}"`
590+
echo "========================================"
591+
echo "Summary Failed Tests... "
592+
echo "========================================"
593+
echo "The following tests FAILED: "
594+
echo "${failed_test_lists_ult}"
595+
exit 8;
596+
fi
542597
fi
543598
fi
544599
}

0 commit comments

Comments
 (0)