未验证 提交 afd8cc42 编写于 作者: Y YUNSHEN XIE 提交者: GitHub

fix coverage combine bug (#50544)

* fix coverage combine bug

* update
上级 7d077000
...@@ -29,12 +29,13 @@ function lcov_init(){ ...@@ -29,12 +29,13 @@ function lcov_init(){
tar -xf /home/lcov-1.14.tar.gz -C / tar -xf /home/lcov-1.14.tar.gz -C /
cd /lcov-1.14 cd /lcov-1.14
make install make install
cd -
} }
function gen_cpp_covinfo(){ function gen_cpp_covinfo(){
# run paddle coverage # run paddle coverage
cd /paddle/build cd /paddle/build
python3.7 ${PADDLE_ROOT}/tools/coverage/gcda_clean.py ${GIT_PR_ID} || exit 101 python ${PADDLE_ROOT}/tools/coverage/gcda_clean.py ${GIT_PR_ID} || exit 101
lcov --capture -d ./ -o coverage.info --rc lcov_branch_coverage=0 lcov --capture -d ./ -o coverage.info --rc lcov_branch_coverage=0
} }
...@@ -126,9 +127,9 @@ function gen_full_html_report_npu() { ...@@ -126,9 +127,9 @@ function gen_full_html_report_npu() {
function gen_diff_html_report() { function gen_diff_html_report() {
if [ "${GIT_PR_ID}" != "" ]; then if [ "${GIT_PR_ID}" != "" ]; then
COVERAGE_DIFF_PATTERN="`python3.7 ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`" COVERAGE_DIFF_PATTERN="`python ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`"
python3.7 ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > git-diff.out python ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > git-diff.out
fi fi
lcov --extract coverage-full.info \ lcov --extract coverage-full.info \
...@@ -136,7 +137,7 @@ function gen_diff_html_report() { ...@@ -136,7 +137,7 @@ function gen_diff_html_report() {
-o coverage-diff.info \ -o coverage-diff.info \
--rc lcov_branch_coverage=0 --rc lcov_branch_coverage=0
python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_diff.py coverage-diff.info git-diff.out > coverage-diff.tmp python ${PADDLE_ROOT}/tools/coverage/coverage_diff.py coverage-diff.info git-diff.out > coverage-diff.tmp
mv -f coverage-diff.tmp coverage-diff.info mv -f coverage-diff.tmp coverage-diff.info
...@@ -149,10 +150,10 @@ function gen_py_covinfo(){ ...@@ -149,10 +150,10 @@ function gen_py_covinfo(){
# python coverage # python coverage
export COVERAGE_FILE=/paddle/build/python-coverage.data export COVERAGE_FILE=/paddle/build/python-coverage.data
coverage combine `$(ls python-coverage.data.*)` || NO_PYTHON_COVERAGE_DATA=1 coverage combine $(ls python-coverage.data.*) || NO_PYTHON_COVERAGE_DATA=1
`$(coverage xml -i -o python-coverage.xml)` || [[ "${NO_PYTHON_COVERAGE_DATA}" == "1" ]] $(coverage xml -i -o python-coverage.xml) || [[ "${NO_PYTHON_COVERAGE_DATA}" == "1" ]]
sed -i 's/mnt\/paddle/paddle/g' python-coverage.xml sed -i 's/mnt\/paddle/paddle/g' python-coverage.xml
`$(python ${PADDLE_ROOT}/tools/coverage/python_coverage.py > python-coverage.info)` || [[ "${NO_PYTHON_COVERAGE_DATA}" == "1" ]] $(python ${PADDLE_ROOT}/tools/coverage/python_coverage.py > python-coverage.info) || [[ "${NO_PYTHON_COVERAGE_DATA}" == "1" ]]
} }
...@@ -180,9 +181,9 @@ function gen_python_full_html_report() { ...@@ -180,9 +181,9 @@ function gen_python_full_html_report() {
function gen_python_diff_html_report() { function gen_python_diff_html_report() {
if [ "${GIT_PR_ID}" != "" ]; then if [ "${GIT_PR_ID}" != "" ]; then
COVERAGE_DIFF_PATTERN="`python3.7 ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`" COVERAGE_DIFF_PATTERN="`python ${PADDLE_ROOT}/tools/coverage/pull_request.py files ${GIT_PR_ID}`"
python3.7 ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > python-git-diff.out python ${PADDLE_ROOT}/tools/coverage/pull_request.py diff ${GIT_PR_ID} > python-git-diff.out
fi fi
lcov --extract python-coverage-full.info \ lcov --extract python-coverage-full.info \
...@@ -190,7 +191,7 @@ function gen_python_diff_html_report() { ...@@ -190,7 +191,7 @@ function gen_python_diff_html_report() {
-o python-coverage-diff.info \ -o python-coverage-diff.info \
--rc lcov_branch_coverage=0 --rc lcov_branch_coverage=0
python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_diff.py python-coverage-diff.info python-git-diff.out > python-coverage-diff.tmp python ${PADDLE_ROOT}/tools/coverage/coverage_diff.py python-coverage-diff.info python-git-diff.out > python-coverage-diff.tmp
mv -f python-coverage-diff.tmp python-coverage-diff.info mv -f python-coverage-diff.tmp python-coverage-diff.info
...@@ -207,34 +208,36 @@ function gen_python_diff_html_report() { ...@@ -207,34 +208,36 @@ function gen_python_diff_html_report() {
# assert coverage lines # assert coverage lines
function covinfo_combine_full(){ function covinfo_combine_full(){
if [ -f "other-coverage.info" ];then if [ -f "other-coverage.info" ] && [ -s "other-coverage.info" ];then
if [ -f "infer-coverage.info" ];then if [ -f "infer-coverage.info" ] && [ -s "infer-coverage.info" ];then
lcov -a other-coverage.info -a infer-coverage.info -o coverage.info lcov -a other-coverage.info -a infer-coverage.info -o coverage.info
else else
mv other-coverage.info coverage.info mv other-coverage.info coverage.info
fi fi
elif [ -f "infer-coverage.info" ];then elif [ -f "infer-coverage.info" ] && [ -s "infer-coverage.info" ];then
mv infer-coverage.info coverage.info mv infer-coverage.info coverage.info
else else
echo "Cannot found coverage.info" echo "Cannot found coverage.info"
fi fi
if [ -f "other-python-coverage-full.info" ];then if [ -f "other-python-coverage.info" ] && [ -s "other-python-coverage.info" ];then
if [ -f "infer-python-coverage-full.info" ];then if [ -f "infer-python-coverage.info" ] && [ -s "other-python-coverage.info" ];then
lcov -a other-python-coverage-full.info -a infer-python-coverage-full.info -o python-coverage-full.info lcov -a other-python-coverage.info -a infer-python-coverage.info -o python-coverage.info
else else
mv other-python-coverage-full.info python-coverage-full.info mv other-python-coverage.info python-coverage.info
fi fi
elif [ -f "infer-coverage.info" ];then elif [ -f "infer-python-coverage.info" ] && [ -s "infer-python-coverage.info" ];then
mv infer-python-coverage-full.info python-coverage-full.info mv infer-python-coverage.info python-coverage.info
else else
echo "Cannot found python coverage.info" echo "Cannot found python coverage.info"
fi fi
gen_python_full_html_report || true
gen_full_html_report || true
} }
function cov_rate_judge(){ function cov_rate_judge(){
echo "Assert CPP Diff Coverage" echo "Assert CPP Diff Coverage"
python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1 python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 || COVERAGE_LINES_ASSERT=1
echo "Assert Python Diff Coverage" echo "Assert Python Diff Coverage"
...@@ -244,7 +247,7 @@ function cov_rate_judge(){ ...@@ -244,7 +247,7 @@ function cov_rate_judge(){
echo "NPU has no python coverage!" echo "NPU has no python coverage!"
else else
if [[ python-coverage-diff.info ]];then if [[ python-coverage-diff.info ]];then
python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1 python ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1
fi fi
fi fi
if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then
...@@ -273,8 +276,8 @@ function main () { ...@@ -273,8 +276,8 @@ function main () {
;; ;;
combine_cov_info) combine_cov_info)
covinfo_combine_full covinfo_combine_full
gen_diff_html_report gen_diff_html_report || true
gen_python_diff_html_report gen_python_diff_html_report || true
cov_rate_judge cov_rate_judge
;; ;;
*) *)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册