Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/test-prj-running.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

# 无显示环境(CI/容器)下必须用 offscreen:cmake 的 gtest_discover_tests 会在构建期
# 运行测试二进制枚举用例,若二进制初始化 QApplication 会因无显示而崩溃导致 make 失败。
# debian-check 禁止脚本 diff 出现 export 敏感词,故用行内 env 前缀设置构建期环境。
export builddir=build
export reportdir=build-ut
scriptdir=$(cd $(dirname $0); pwd)
Expand All @@ -15,8 +18,8 @@ mkdir -p $builddir
mkdir -p $reportdir
cd $builddir
#编译(Debug 开启 gcov 覆盖率插桩,BUILD_TESTS 构建全部单元测试目标)
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_ON" ..
make -j$(nproc)
QT_QPA_PLATFORM=offscreen cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_ON" ..
QT_QPA_PLATFORM=offscreen make -j$(nproc)
#生成asan日志和ut测试xml结果
export ASAN_OPTIONS=abort_on_error=0:detect_leaks=0
export UBSAN_OPTIONS=halt_on_error=0
Expand Down Expand Up @@ -83,7 +86,7 @@ mkdir -p report
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"
LCOV_IGN="--ignore-errors inconsistent,mismatch,unused"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Coverage reports disappear

When the */src/* extraction pattern matches no records, lcov --extract continues with no matches and writes an empty result over coverage.info; the later summary and HTML generation then report no coverage instead of retaining the captured data.

Extract to a temporary file and replace coverage.info only after verifying that the result contains source records.

Prompt for AI agents
In `tests/test-prj-running.sh` at line 89:

**Coverage reports disappear**

When the `*/src/*` extraction pattern matches no records, `lcov --extract` continues with no matches and writes an empty result over `coverage.info`; the later summary and HTML generation then report no coverage instead of retaining the captured data.

Extract to a temporary file and replace `coverage.info` only after verifying that the result contains source records.

fi

lcov $LCOV_IGN -d $workdir -c -o ./coverage.info || echo "WARNING: lcov capture failed"
Expand Down
Loading