diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 8b0bed07f681b32fa0ef4ebb398814a94bb5acae..ea49bbd5810ad50c14f515b740fb5e09fccdd8d3 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -2539,6 +2539,7 @@ set -x bash $PADDLE_ROOT/tools/check_added_ut.sh #check change of pr_unnitests and dev_unnitests check_approvals_of_unittest 2 + ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' > ${PADDLE_ROOT}/build/all_ut_list if [ ${PRECISION_TEST:-OFF} == "ON" ]; then python3.7 $PADDLE_ROOT/tools/get_pr_ut.py fi @@ -2571,7 +2572,6 @@ set +x mkdir -p ${PADDLE_ROOT}/build/Testing/Temporary/ cp -r ${PADDLE_ROOT}/build/CTestCostData.txt ${PADDLE_ROOT}/build/Testing/Temporary/ - ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' > all_ut_list get_quickly_disable_ut||disable_ut_quickly='disable_ut' # indicate whether the case was in quickly disable list test_cases=$(ctest -N -V) # get all test cases diff --git a/tools/get_pr_ut.py b/tools/get_pr_ut.py index 3fee302aa4f1938656a2a58f0f0e8ea0667ea790..d3a1c41682bd9b2a54fdd36682f9e50765e07c5b 100644 --- a/tools/get_pr_ut.py +++ b/tools/get_pr_ut.py @@ -280,11 +280,12 @@ class PRChecker(object): def file_is_unnit_test(self, unittest_path): # get all testcases by ctest-N - all_ut_file = '%s/build/all_ut_file' % PADDLE_ROOT - os.system( - "cd %s/build && ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' > %s" - % (PADDLE_ROOT, all_ut_file) - ) + all_ut_file = PADDLE_ROOT + 'build/all_ut_list' + # all_ut_file = '%s/build/all_ut_file' % PADDLE_ROOT + print("PADDLE_ROOT:", PADDLE_ROOT) + print("all_ut_file path:", all_ut_file) + build_path = PADDLE_ROOT + 'build/' + print("build_path:", build_path) (unittest_directory, unittest_name) = os.path.split(unittest_path) # determine whether filename is in all_ut_case with open(all_ut_file, 'r') as f: @@ -293,8 +294,7 @@ class PRChecker(object): test = test.replace('\n', '').strip() if test == unittest_name.split(".")[0]: return True - else: - return False + return False def get_pr_ut(self): """Get unit tests in pull request.""" @@ -410,17 +410,17 @@ class PRChecker(object): # determine whether the new added file is a member of added_ut if file_dict[f] in ['added']: f_judge_in_added_ut = False - with open( - '{}/added_ut'.format(PADDLE_ROOT) - ) as utfile: - (filepath, tempfilename) = os.path.split( - f_judge - ) - for f_file in utfile: - if ( - f_file.strip('\n') - == tempfilename.split(".")[0] - ): + path = PADDLE_ROOT + 'added_ut' + print("PADDLE_ROOT:", PADDLE_ROOT) + print("adde_ut path:", path) + (unittest_directory, unittest_name) = os.path.split( + f_judge + ) + with open(path, 'r') as f: + added_unittests = f.readlines() + for test in added_unittests: + test = test.replace('\n', '').strip() + if test == unittest_name.split(".")[0]: f_judge_in_added_ut = True if f_judge_in_added_ut: print( diff --git a/tools/windows/run_unittests.sh b/tools/windows/run_unittests.sh index ac70fc0b7540789be9aa2ef1d9b29f3f7932f0ce..6f2e84f427a41af7c1eb494bc108ba57e78f850a 100644 --- a/tools/windows/run_unittests.sh +++ b/tools/windows/run_unittests.sh @@ -280,7 +280,7 @@ rm -rf $PADDLE_ROOT/tools/check_added_ut_win.sh if [ -f "$PADDLE_ROOT/added_ut" ];then added_uts=^$(awk BEGIN{RS=EOF}'{gsub(/\n/,"$|^");print}' $PADDLE_ROOT/added_ut)$ ctest -R "(${added_uts})" -E "${disable_win_inference_test}" --output-on-failure -C Release --repeat-until-fail 3;added_ut_error=$? - rm -f $PADDLE_ROOT/added_ut + #rm -f $PADDLE_ROOT/added_ut if [ "$added_ut_error" != 0 ];then echo "========================================" echo "Added UT should pass three additional executions"