From 4325da3980f12e77f47dae37218a4577ddc7f80c Mon Sep 17 00:00:00 2001 From: risemeup1 <62429225+risemeup1@users.noreply.github.com> Date: Wed, 2 Nov 2022 13:44:44 +0800 Subject: [PATCH] Modify test file (#47544) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修改.gitigore文件,把ljd_sh文件忽略掉 * 修复改动单测文件没有触发精准测试的问题 * 取消改动.gitignore * 修复改动单测没有出发精准测试的问题 * 修改变量名含义更加容易理解,test=coverage --- tools/get_pr_ut.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/get_pr_ut.py b/tools/get_pr_ut.py index fcfa68bb4da..59f11081884 100644 --- a/tools/get_pr_ut.py +++ b/tools/get_pr_ut.py @@ -278,18 +278,20 @@ class PRChecker(object): all_counts = line.split()[-1] return int(all_counts) - def file_is_unnit_test(self, filename): + 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) ) + (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: - (filepath, tempfilename) = os.path.split(filename) - for f_file in f: - if f_file.strip('\n') == tempfilename.split(".")[0]: + all_unittests = f.readlines() + for test in all_unittests: + test = test.replace('\n', '').strip() + if test == unittest_name.split(".")[0]: return True else: return False -- GitLab