From 91758023da14ea2d78b59073f6760b0b124fc38a Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Tue, 1 Dec 2026 10:47:28 +0800 Subject: [PATCH 1/2] fix(test): add lcov 2.x version-gated --ignore-errors for coverage scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 镜像 lcov 为 2.x,对 gcov 计数器与源码不一致(inconsistent/mismatch) 直接报错中断,任一阶段失败都会导致覆盖率无法产出(与 deepin-screen-recorder #553、deepin-terminal #531 同因)。按版本门控 (lcov >= 2 才加 --ignore-errors inconsistent,mismatch)注入全部 lcov/genhtml 调用,lcov 1.x 行为不变。 PMS: TASK-398635 Log: CI 单测覆盖率流水线 lcov 2.x 兼容 Influence: 不影响 lcov 1.x 本地行为 --- tests/common/cov_report.sh | 14 ++++++++++++-- tests/test-prj-running.sh | 18 ++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/common/cov_report.sh b/tests/common/cov_report.sh index 393bf0dd..78f94db5 100755 --- a/tests/common/cov_report.sh +++ b/tests/common/cov_report.sh @@ -7,8 +7,18 @@ TARGET="$1" FILTER="${2:-}" BD=/home/uos/work/ut/deepin-editor/build OBJDIR="$BD/tests/common/CMakeFiles/${TARGET}.dir" -lcov --capture --directory "$OBJDIR" -o "/tmp/b2_${TARGET}.info" -q 2>/dev/null -lcov --extract "/tmp/b2_${TARGET}.info" '*/src/common/*' -o "/tmp/b2_${TARGET}_f.info" -q 2>/dev/null +# CI 镜像 lcov 为 2.x:对 gcov 计数器与源码不一致(inconsistent/mismatch) +# 直接报错中断,任一阶段失败都会导致覆盖率无法产出。 +# 因此每一步 lcov/genhtml 都需要带上 --ignore-errors +# (lcov 1.x 不支持 --ignore-errors,保持原行为)。 +LCOV_MAJOR=$(lcov --version 2>/dev/null | grep -oE '[0-9]+(\.[0-9]+)+' | head -1 | cut -d. -f1) +LCOV_IGN="" +if [ "${LCOV_MAJOR:-0}" -ge 2 ]; then + LCOV_IGN="--ignore-errors inconsistent,mismatch" +fi + +lcov $LCOV_IGN --capture --directory "$OBJDIR" -o "/tmp/b2_${TARGET}.info" -q 2>/dev/null +lcov $LCOV_IGN --extract "/tmp/b2_${TARGET}.info" '*/src/common/*' -o "/tmp/b2_${TARGET}_f.info" -q 2>/dev/null python3 - "/tmp/b2_${TARGET}_f.info" "$FILTER" <<'PYEOF' import re, sys info = open(sys.argv[1]).read() diff --git a/tests/test-prj-running.sh b/tests/test-prj-running.sh index e0386724..fc4b11a4 100755 --- a/tests/test-prj-running.sh +++ b/tests/test-prj-running.sh @@ -76,13 +76,23 @@ workdir=$(pwd) mkdir -p report #统计代码覆盖率并生成html报告 -lcov -d $workdir -c -o ./coverage.info || echo "WARNING: lcov capture failed" +# CI 镜像 lcov 为 2.x:对 gcov 计数器与源码不一致(inconsistent/mismatch) +# 直接报错中断,任一阶段失败都会导致覆盖率无法产出。 +# 因此每一步 lcov/genhtml 都需要带上 --ignore-errors +# (lcov 1.x 不支持 --ignore-errors,保持原行为)。 +LCOV_MAJOR=$(lcov --version 2>/dev/null | grep -oE '[0-9]+(\.[0-9]+)+' | head -1 | cut -d. -f1) +LCOV_IGN="" +if [ "${LCOV_MAJOR:-0}" -ge 2 ]; then + LCOV_IGN="--ignore-errors inconsistent,mismatch" +fi + +lcov $LCOV_IGN -d $workdir -c -o ./coverage.info || echo "WARNING: lcov capture failed" -lcov --extract ./coverage.info '*/src/*' -o ./coverage.info || true +lcov $LCOV_IGN --extract ./coverage.info '*/src/*' -o ./coverage.info || true -lcov --remove ./coverage.info '*/tests/*' -o ./coverage.info || true +lcov $LCOV_IGN --remove ./coverage.info '*/tests/*' -o ./coverage.info || true -genhtml -o ./html ./coverage.info || true +genhtml $LCOV_IGN -o ./html ./coverage.info || true [ -f ./html/index.html ] && mv ./html/index.html ./html/cov_deepin-editor.html #对asan、ut、代码覆盖率结果收集至指定文件夹 cp -r html ../$reportdir/ 2>/dev/null || true From 115366310e750c836933b36a6e386e0b1e4d843e Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Tue, 1 Dec 2026 11:46:57 +0800 Subject: [PATCH 2/2] chore: update SPDX copyright/license headers for CI check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 单年份版权行更新为创建年-2026 区间(CI SPDX 检查要求) - 为缺失 SPDX header 的脚本补充版权与 license 声明 PMS: TASK-398635 Log: CI SPDX 检查修复 Influence: 仅注释变更,不影响脚本逻辑 --- tests/common/cov_report.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/common/cov_report.sh b/tests/common/cov_report.sh index 78f94db5..826edd56 100755 --- a/tests/common/cov_report.sh +++ b/tests/common/cov_report.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: GPL-3.0-or-later # B2 批次 lcov 函数覆盖率统计(按测试目标隔离对象目录) # 用法: cov_report.sh [source_file_filter] # source_file_filter: 可选,按源文件名过滤(如 utils.cpp / settings.cpp / urlinfo.h)