diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 0b8a0686f0ed4fb379b065849217dd9b8a1c8ac0..22ba30c5c8d5d3c75109ae98794e234dd3089d5f 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -607,7 +607,16 @@ EOF echo "Unittests with nightly labels are only run at night" echo "=========================================" fi - ctest -E "($disable_ut_quickly)" -LE ${nightly_label} --output-on-failure -j $2 | tee $tmpfile + bash $PADDLE_ROOT/tools/check_added_ut.sh + get_precision_ut_mac + if [[ "$on_precision" == "0" ]];then + ctest -E "($disable_ut_quickly)" -LE ${nightly_label} --output-on-failure -j $2 | tee $tmpfile + else + ctest -R "($UT_list_prec)" -E "($disable_ut_quickly)" -LE ${nightly_label} --output-on-failure -j $2 | tee $tmpfile + tmpfile_rand=`date +%s%N` + tmpfile=$tmp_dir/$tmpfile_rand + ctest -R "($UT_list_prec_1)" -E "($disable_ut_quickly)" -LE ${nightly_label} --output-on-failure -j $2 | tee $tmpfile + fi failed_test_lists='' collect_failed_tests mactest_error=0 @@ -672,6 +681,42 @@ EOF fi } +function get_precision_ut_mac() { + on_precision=0 + set -x + UT_list=$(ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d') + precison_cases="" + if [ ${PRECISION_TEST:-OFF} == "ON" ]; then + python3.7 $PADDLE_ROOT/tools/get_pr_ut.py + if [[ -f "ut_list" ]]; then + set +x + echo "PREC length: "`wc -l ut_list` + precision_cases=`cat ut_list` + set -x + fi + fi + if [ ${PRECISION_TEST:-OFF} == "ON" ] && [[ "$precision_cases" != "" ]];then + UT_list_re='' + on_precision=1 + re=$(cat ut_list|awk -F ' ' '{print }' | awk 'BEGIN{ all_str=""}{if (all_str==""){all_str=$1}else{all_str=all_str"$|^"$1}} END{print "^"all_str"$"}') + UT_list_prec_1='ut_list_prec2' + for case in $UT_list; do + flag=$(echo $case|grep -oE $re) + if [ -n "$flag" ];then + if [ -z "$UT_list_prec" ];then + UT_list_prec="^$case$" + elif [[ "${#UT_list_prec}" -gt 10000 ]];then + UT_list_prec_1="$UT_list_prec_1|^$case$" + else + UT_list_prec="$UT_list_prec|^$case$" + fi + else + echo ${case} "won't run in PRECISION_TEST mode." + fi + done + fi +} + function fetch_upstream_develop_if_not_exist() { UPSTREAM_URL='https://github.com/PaddlePaddle/Paddle' origin_upstream_url=`git remote -v | awk '{print $1, $2}' | uniq | grep upstream | awk '{print $2}'` diff --git a/tools/get_pr_ut.py b/tools/get_pr_ut.py index 6b26ede908e48e0e342cafe2bc52f38b832412aa..e97f69faf02c1fe32abcd2b919508e25571b7659 100644 --- a/tools/get_pr_ut.py +++ b/tools/get_pr_ut.py @@ -20,6 +20,7 @@ import sys import time import subprocess import requests +import platform from github import Github PADDLE_ROOT = os.getenv('PADDLE_ROOT', '/paddle/') @@ -210,6 +211,10 @@ class PRChecker(object): with open('file_ut.json' + self.suffix) as jsonfile: file_ut_map = json.load(jsonfile) for f in self.get_pr_files(): + current_system = platform.system() + if current_system == "Darwin" or current_system == "Windows": + f = f.replace(PADDLE_ROOT, '/paddle/', 1) + f = f.replace('//', '/') if f not in file_ut_map: if f.endswith('.md'): ut_list.append('md_placeholder')