未验证 提交 944f8ae0 编写于 作者: C chalsliu 提交者: GitHub

Upgrade coverage tool to python3

上级 753a0748
......@@ -90,12 +90,12 @@ def get_info_file_lines(info_file, diff_file):
continue
elif line.startswith('LF:'):
print 'LF:{}'.format(current_lf)
print('LF:{}'.format(current_lf))
continue
elif line.startswith('LH:'):
print 'LH:{}'.format(current_lh)
print('LH:{}'.format(current_lh))
continue
......
......@@ -40,7 +40,7 @@ def filter_by(list_file, max_rate):
except:
pass
print name, rate
print(name, rate)
if __name__ == '__main__':
......
......@@ -33,7 +33,7 @@ def get_lines(info_file):
hits += 1
if total == 0:
print 'no data found'
print('no data found')
exit()
return hits / total
......@@ -47,17 +47,17 @@ if __name__ == '__main__':
expected = float(sys.argv[2])
if not os.path.isfile(info_file):
print 'info file {} is not exists, ignored'.format(info_file)
print('info file {} is not exists, ignored'.format(info_file))
exit()
actual = get_lines(info_file)
actual = round(actual, 3)
if actual < expected:
print 'expected >= {} %, actual {} %, failed'.format(
round(expected * 100, 1), round(actual * 100, 1))
print('expected >= {} %, actual {} %, failed'.format(
round(expected * 100, 1), round(actual * 100, 1)))
exit(1)
print 'expected >= {} %, actual {} %, passed'.format(
round(expected * 100, 1), round(actual * 100, 1))
print('expected >= {} %, actual {} %, passed'.format(
round(expected * 100, 1), round(actual * 100, 1)))
......@@ -5,7 +5,7 @@ set -xe
PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )"
# install lcov
curl -o /lcov-1.14.tar.gz -x "" -s https://paddle-ci.gz.bcebos.com/coverage/lcov-1.14.tar.gz
curl -o /lcov-1.14.tar.gz -s https://paddle-ci.gz.bcebos.com/coverage%2Flcov-1.14.tar.gz
tar -xf /lcov-1.14.tar.gz -C /
cd /lcov-1.14
make install
......@@ -14,7 +14,7 @@ make install
cd /paddle/build
python ${PADDLE_ROOT}/tools/coverage/gcda_clean.py ${GIT_PR_ID}
python3 ${PADDLE_ROOT}/tools/coverage/gcda_clean.py ${GIT_PR_ID}
lcov --capture -d ./ -o coverage.info --rc lcov_branch_coverage=0
......@@ -53,9 +53,9 @@ gen_full_html_report || true
function gen_diff_html_report() {
if [ "${GIT_PR_ID}" != "" ]; then
COVERAGE_DIFF_PATTERN="`python ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`"
COVERAGE_DIFF_PATTERN="`python3 ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`"
python ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > git-diff.out
python3 ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > git-diff.out
fi
lcov --extract coverage-full.info \
......@@ -63,7 +63,7 @@ function gen_diff_html_report() {
-o coverage-diff.info \
--rc lcov_branch_coverage=0
python ${PADDLE_ROOT}/tools/coverage/coverage_diff.py coverage-diff.info git-diff.out > coverage-diff.tmp
python3 ${PADDLE_ROOT}/tools/coverage/coverage_diff.py coverage-diff.info git-diff.out > coverage-diff.tmp
mv -f coverage-diff.tmp coverage-diff.info
......@@ -82,7 +82,7 @@ set -x
coverage xml -i -o python-coverage.xml
python ${PADDLE_ROOT}/tools/coverage/python_coverage.py > python-coverage.info
python3 ${PADDLE_ROOT}/tools/coverage/python_coverage.py > python-coverage.info
# python full html report
#
......@@ -143,5 +143,6 @@ echo "Assert Python Diff Coverage"
python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
echo "exit 9" > /tmp/paddle_coverage.result
exit 9
fi
......@@ -40,7 +40,7 @@ def get_files(args):
pull = get_pull(args.pull_id)
for file in pull.get_files():
print '/paddle/{}'.format(file.filename)
print('/paddle/{}'.format(file.filename))
def diff(args):
......@@ -55,8 +55,8 @@ def diff(args):
pull = get_pull(args.pull_id)
for file in pull.get_files():
print '+++ {}'.format(file.filename)
print file.patch
print('+++ {}'.format(file.filename))
print(file.patch)
if __name__ == '__main__':
......
......@@ -12,10 +12,7 @@ root = tree.getroot()
sources = root.findall('sources/source')
if len(sources) > 1:
exit(1)
source = sources[0].text
source = sources[-1].text
for clazz in root.findall('packages/package/classes/class'):
clazz_filename = clazz.attrib.get('filename')
......@@ -28,8 +25,8 @@ for clazz in root.findall('packages/package/classes/class'):
if not path.exists(clazz_filename):
continue
print 'TN:'
print 'SF:{}'.format(clazz_filename)
print('TN:')
print('SF:{}'.format(clazz_filename))
branch_index = 0
......@@ -50,16 +47,16 @@ for clazz in root.findall('packages/package/classes/class'):
taken = int(taken)
for _ in range(taken):
print 'BRDA:{},{},{},{}'.format(line_number, 0, branch_index,
line_hits)
print('BRDA:{},{},{},{}'.format(line_number, 0, branch_index,
line_hits))
branch_index += 1
if line_missing_branches:
for missing_branch in line_missing_branches.split(','):
print 'BRDA:{},{},{},{}'.format(line_number, 0,
branch_index, 0)
print('BRDA:{},{},{},{}'.format(line_number, 0,
branch_index, 0))
branch_index += 1
print 'DA:{},{}'.format(line_number, line_hits)
print('DA:{},{}'.format(line_number, line_hits))
print 'end_of_record'
print('end_of_record')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册