未验证 提交 4e8ad06a 编写于 作者: R risemeup1 提交者: GitHub

this pr is for optimizing precise test (#46068)

* this pr is for optimizing precise test

* modify get_pr_ut.py

* modify get_pr_ut.py
上级 0a904f8b
......@@ -264,6 +264,21 @@ class PRChecker(object):
all_counts = line.split()[-1]
return int(all_counts)
def file_is_unnit_test(self, filename):
#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))
#determine whether filename is in all_ut_case
with open(all_ut_file, 'r') as f:
(filepath, tempfilename) = os.path.split(filename)
for f_file in f:
if f_file.strip('\n') == tempfilename.split(".")[0]:
return True
else:
return False
def get_pr_ut(self):
""" Get unit tests in pull request. """
if self.full_case:
......@@ -351,18 +366,34 @@ class PRChecker(object):
elif 'tests/unittests/xpu' in f_judge or 'tests/unittests/npu' in f_judge or 'op_npu.cc' in f_judge:
ut_list.append('xpu_npu_placeholder')
onlyCommentsFilesOrXpu.append(f_judge)
elif f_judge.endswith(('.h', '.cu', '.cc', 'py')):
if f_judge.find('test_') != -1 or f_judge.find(
'_test') != -1:
check_added_ut = True
if file_dict[f] not in ['removed']:
elif f_judge.endswith(('.h', '.cu', '.cc', '.py')):
#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]:
f_judge_in_added_ut = True
if f_judge_in_added_ut == True:
print(
"Adding new unit tests not hit mapFiles: %s"
% f_judge)
else:
notHitMapFiles.append(f_judge)
elif file_dict[f] in ['removed']:
print("remove file not hit mapFiles: %s" % f_judge)
else:
if self.is_only_comment(f):
ut_list.append('comment_placeholder')
onlyCommentsFilesOrXpu.append(f_judge)
if self.file_is_unnit_test(f_judge):
ut_list.append(f_judge.split(".")[0])
else:
notHitMapFiles.append(f_judge)
else:
print("remove file not hit mapFiles: %s" % f_judge)
else:
notHitMapFiles.append(
f_judge) if file_dict[f] != 'removed' else print(
......@@ -387,10 +418,6 @@ class PRChecker(object):
print("filterFiles: %s" % filterFiles)
return ''
else:
if check_added_ut:
with open('{}/added_ut'.format(PADDLE_ROOT)) as utfile:
for ut in utfile:
ut_list.append(ut.rstrip('\r\n'))
if ut_list:
ret = self.__urlretrieve(
'https://paddle-docker-tar.bj.bcebos.com/pre_test/prec_delta',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册