Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
944f8ae0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
944f8ae0
编写于
9月 08, 2020
作者:
C
chalsliu
提交者:
GitHub
9月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upgrade coverage tool to python3
上级
753a0748
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
28 addition
and
30 deletion
+28
-30
tools/coverage/coverage_diff.py
tools/coverage/coverage_diff.py
+2
-2
tools/coverage/coverage_diff_list.py
tools/coverage/coverage_diff_list.py
+1
-1
tools/coverage/coverage_lines.py
tools/coverage/coverage_lines.py
+6
-6
tools/coverage/paddle_coverage.sh
tools/coverage/paddle_coverage.sh
+7
-6
tools/coverage/pull_request.py
tools/coverage/pull_request.py
+3
-3
tools/coverage/python_coverage.py
tools/coverage/python_coverage.py
+9
-12
未找到文件。
tools/coverage/coverage_diff.py
浏览文件 @
944f8ae0
...
...
@@ -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
...
...
tools/coverage/coverage_diff_list.py
浏览文件 @
944f8ae0
...
...
@@ -40,7 +40,7 @@ def filter_by(list_file, max_rate):
except
:
pass
print
name
,
rate
print
(
name
,
rate
)
if
__name__
==
'__main__'
:
...
...
tools/coverage/coverage_lines.py
浏览文件 @
944f8ae0
...
...
@@ -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
))
)
tools/coverage/paddle_coverage.sh
浏览文件 @
944f8ae0
...
...
@@ -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%2F
lcov-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
}
python
3
${
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
=
"
`
python
3
${
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
python
3
${
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
python
3
${
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
python
3
${
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
tools/coverage/pull_request.py
浏览文件 @
944f8ae0
...
...
@@ -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__'
:
...
...
tools/coverage/python_coverage.py
浏览文件 @
944f8ae0
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录