Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 17 additions & 7 deletions tests/local-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -24,20 +24,30 @@ remove_info="*/tests/*"

$build_dir/$executable --gtest_output=xml:$result_report_dir

lcov -d $build_dir -c -o $build_dir/coverage.info
# 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 --remove $build_dir/coverage.info $remove_info --output-file $build_dir/coverage.info
lcov $LCOV_IGN -d $build_dir -c -o $build_dir/coverage.info

lcov --extract $build_dir/coverage.info $extract_info --output-file $build_dir/coverage.info
lcov $LCOV_IGN --remove $build_dir/coverage.info $remove_info --output-file $build_dir/coverage.info

lcov --list-full-path -e $build_dir/coverage.info –o $build_dir/coverage-stripped.info
lcov $LCOV_IGN --extract $build_dir/coverage.info $extract_info --output-file $build_dir/coverage.info

genhtml -o $result_coverage_dir $build_dir/coverage.info
lcov $LCOV_IGN --list-full-path -e $build_dir/coverage.info -o $build_dir/coverage-stripped.info

genhtml $LCOV_IGN -o $result_coverage_dir $build_dir/coverage.info

nohup x-www-browser $result_coverage_dir/index.html &

nohup x-www-browser $result_report_dir &

lcov -d $build_dir –z
lcov $LCOV_IGN -d $build_dir -z

exit 0
20 changes: 15 additions & 5 deletions tests/qmake-lcov-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -16,12 +16,22 @@ result_report_dir=$build_dir/report/report.xml

$build_dir/$executable --gtest_output=xml:$result_report_dir

lcov -d $build_dir -c -o $build_dir/coverage.info
# 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 --extract $build_dir/coverage.info '*/reader/*' -o $build_dir/coverage.info
lcov $LCOV_IGN -d $build_dir -c -o $build_dir/coverage.info

lcov --remove $build_dir/coverage.info '*/tests/*' -o $build_dir/coverage.info
lcov $LCOV_IGN --extract $build_dir/coverage.info '*/reader/*' -o $build_dir/coverage.info

genhtml -o $result_coverage_dir $build_dir/coverage.info
lcov $LCOV_IGN --remove $build_dir/coverage.info '*/tests/*' -o $build_dir/coverage.info

genhtml $LCOV_IGN -o $result_coverage_dir $build_dir/coverage.info

exit 0
20 changes: 15 additions & 5 deletions tests/test-prj-running.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ set -e
workdir="${build_path}"

# Reset any stale coverage counters before recapture
lcov --directory "${workdir}" --zerocounters || true
# 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 --directory "${workdir}" --zerocounters || true

# Re-run tests so .gcda files reflect a clean run
# If the first run segfaulted, .gcda files won't exist (atexit not called on SIGSEGV).
Expand Down Expand Up @@ -88,17 +98,17 @@ fi
test_exit_code=$((test_exit_code || retest_exit_code))

# Collect coverage data
lcov -d "${workdir}" -c -o ./coverage.info
lcov $LCOV_IGN -d "${workdir}" -c -o ./coverage.info

# Keep only reader/htmltopdf sources, drop tests themselves
lcov --extract ./coverage.info '*/reader/*' '*/htmltopdf/*' -o ./coverage.info
lcov --remove ./coverage.info '*/tests/*' -o ./coverage.info
lcov $LCOV_IGN --extract ./coverage.info '*/reader/*' '*/htmltopdf/*' -o ./coverage.info
lcov $LCOV_IGN --remove ./coverage.info '*/tests/*' -o ./coverage.info

# Exclude compiler-generated and unreachable functions (D0Ev, Q_OBJECT tr, env-dependent lambdas)
python3 "${scriptdir}/exclude_unreachable.py" ./coverage.info ./coverage.info

# Generate HTML report
genhtml -o ./html ./coverage.info
genhtml $LCOV_IGN -o ./html ./coverage.info

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 summary drops metrics

When lcov 2.x encounters inconsistent or mismatched data while producing the summary, gen-ut-summary.py later runs lcov --summary without the version-gated ignore option; when that command rejects mismatched coverage data, its output has no metrics for the parser, so ut-summary.json is written without coverage fields.

Pass the same version-gated ignore option to the summary invocation, or otherwise handle a failed summary without silently omitting its metrics.

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

**Coverage summary drops metrics**

When lcov 2.x encounters inconsistent or mismatched data while producing the summary, `gen-ut-summary.py` later runs `lcov --summary` without the version-gated ignore option; when that command rejects mismatched coverage data, its output has no metrics for the parser, so `ut-summary.json` is written without coverage fields.

Pass the same version-gated ignore option to the summary invocation, or otherwise handle a failed summary without silently omitting its metrics.


# Rename main index for downstream tooling
mv ./html/index.html ./html/cov_deepin-reader.html
Expand Down
Loading