Merged
fix: 统一 lcov 忽略错误参数以兼容 lcov>=2.0 覆盖率生成 #574
songkai111Add on Jun 29
fix: 统一 lcov 忽略错误参数以兼容 lcov>=2.0 覆盖率生成 #574
Merged
songkai111Add on Jun 29
Total: 1 files changed+8-4
@@ -16,6 +16,10 @@ logging_error() {
16 echo "[ERROR] $@"16 echo "[ERROR] $@"
17}17}
18 18 
19+# lcov >= 2.0 is strict about several conditions that older versions tolerated.
20+# Provide a single ignore set so coverage generation is robust across versions.
21+LCOV_IGNORE_ERRORS="--ignore-errors mismatch,inconsistent,empty,negative"
22+ 
19mk_dir() {23mk_dir() {
20 local create_dir="$1"24 local create_dir="$1"
21 mkdir -pv "${create_dir}"25 mkdir -pv "${create_dir}"
@@ -53,8 +57,8 @@ generate_coverage() {
53 mk_dir "${_path_to_gen}"57 mk_dir "${_path_to_gen}"
54 fi58 fi
55 59 
56- lcov -c -d "${_source_dir}" -o "${_coverage_file}"60+ lcov -c -d "${_source_dir}" -o "${_coverage_file}" ${LCOV_IGNORE_ERRORS}
57- lcov --ignore-errors inconsistent -r "${_coverage_file}" "${ASCEND_PARENT_PATH}/*" -o "${_coverage_file}"61+ lcov ${LCOV_IGNORE_ERRORS} -r "${_coverage_file}" "${ASCEND_PARENT_PATH}/*" -o "${_coverage_file}"
58 logging "generated coverage file ${_coverage_file}"62 logging "generated coverage file ${_coverage_file}"
59}63}
60 64 
@@ -77,7 +81,7 @@ filter_coverage() {
77 lcov --remove "${_coverage_file}" '${ASCEND_PARENT_PATH}/*'\81 lcov --remove "${_coverage_file}" '${ASCEND_PARENT_PATH}/*'\
78 '/usr/include/*' \82 '/usr/include/*' \
79 '*/third_party/*' \83 '*/third_party/*' \
80- '*/tests/*' -o "${_filtered_file}" --ignore-errors inconsistent84+ '*/tests/*' -o "${_filtered_file}" ${LCOV_IGNORE_ERRORS}
81}85}
82 86 
83# generate html report87# generate html report
@@ -94,7 +98,7 @@ generate_html() {
94 if [[ ! -d "${_out_path}" ]]; then98 if [[ ! -d "${_out_path}" ]]; then
95 mk_dir "${_out_path}"99 mk_dir "${_out_path}"
96 fi100 fi
97- genhtml "${_filtered_file}" -o "${_out_path}"101+ genhtml "${_filtered_file}" -o "${_out_path}" ${LCOV_IGNORE_ERRORS}
98}102}
99 103 
100 104