diff --git a/tools/get_pr_ut.py b/tools/get_pr_ut.py index 5d15443e3840cc99234da9b6b4f34b9b790a1013..78d9978c4bc45e0917c6de71a8220ca62959f028 100644 --- a/tools/get_pr_ut.py +++ b/tools/get_pr_ut.py @@ -248,13 +248,15 @@ class PRChecker(object): return True def get_all_count(self): - os.system( - "cd %sbuild && ctest -N|grep 'Total Tests:' | awk -F ': ' '{print $2}' > testCount" - % PADDLE_ROOT) - f = open("%sbuild/testCount" % PADDLE_ROOT) - testCount = f.read() - f.close() - return int(testCount.strip()) + p = subprocess.Popen( + "cd {}build && ctest -N".format(PADDLE_ROOT), + shell=True, + stdout=subprocess.PIPE) + out, err = p.communicate() + for line in out.splitlines(): + if 'Total Tests:' in str(line): + all_counts = line.split()[-1] + return int(all_counts) def get_pr_ut(self): """ Get unit tests in pull request. """