From 0b3c229606207acaca8b9625c2d7748c83ba7e2f Mon Sep 17 00:00:00 2001 From: YUNSHEN XIE <1084314248@qq.com> Date: Tue, 9 Mar 2021 20:35:32 +0800 Subject: [PATCH] Prec on mac (#31382) * add precision on mac * added judge * match file_ut.json on mac * fix code format error * fix code format error * fix error caused by length of ut_lists exceeds the limit * fix format error,notest,test=cpu * fix code format error * add windows judge on get_pr_ut --- paddle/scripts/paddle_build.sh | 47 +++++++++++++++++++++++++++++++++- tools/get_pr_ut.py | 5 ++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 0b8a0686f0e..22ba30c5c8d 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 6b26ede908e..e97f69faf02 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') -- GitLab