Skip to content

fix(ut): suppress lcov 2.x unused error for extract patterns - #468

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-ut-lcov-unused
Dec 1, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-ut-lcov-unused

Conversation

@add-uos

@add-uos add-uos commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

fix(ut): suppress lcov 2.x unused error for extract patterns

Log: CI 镜像 lcov 2.x 对 --extract 未命中的 include pattern 直接报
ERROR (unused),1.x 仅警告;脚本 set -e 中断导致 ut-summary.json
未产出,流水线覆盖率记 0。统一在 --ignore-errors 中追加 unused。
Influence: 仅影响 UT 流水线覆盖率采集脚本,lcov 1.x 行为不变。

PMS: TASK-398635

Summary by Sourcery

Bug Fixes:

  • Prevent lcov 2.x from aborting UT coverage collection when an --extract include pattern is unused, allowing coverage reports to be generated.

@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Allow lcov 2.x to continue coverage collection when an extract pattern matches no files by adding the unused error to the ignored error list in all three UT scripts.

  • tests/local-test.sh L34
  • tests/qmake-lcov-test.sh L26
  • tests/test-prj-running.sh L62

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/local-test.sh" line_range="34" />
<code_context>
 LCOV_IGN=""
 if [ "${LCOV_MAJOR:-0}" -ge 2 ]; then
-    LCOV_IGN="--ignore-errors inconsistent,mismatch"
+    LCOV_IGN="--ignore-errors inconsistent,mismatch,unused"
 fi

</code_context>
<issue_to_address>
**Coverage artifacts omit expected sources**

When all configured `--extract` patterns match no tracefile records, `LCOV_IGN` suppresses the `unused` error, and the scripts do not verify the extraction result, so collection succeeds with empty or incomplete coverage artifacts.

Check that extraction selects the intended source records and fail collection when it does not.

Also at `tests/qmake-lcov-test.sh:26`, `tests/test-prj-running.sh:62`.
</issue_to_address>

### Comment 2
<location path="tests/local-test.sh" line_range="34" />
<code_context>
 LCOV_IGN=""
 if [ "${LCOV_MAJOR:-0}" -ge 2 ]; then
-    LCOV_IGN="--ignore-errors inconsistent,mismatch"
+    LCOV_IGN="--ignore-errors inconsistent,mismatch,unused"
 fi

</code_context>
<issue_to_address>
**Test code inflates project coverage**

When test source paths do not match the removal glob, `LCOV_IGN` also reaches each `lcov --remove` command, suppressing its `unused` error; test records remain in `coverage.info`, so the report counts test code as project coverage.

Do not pass the `unused` ignore setting to `lcov --remove`, so unmatched exclusion patterns fail rather than leave test records in the report.

Also at `tests/qmake-lcov-test.sh:26`, `tests/test-prj-running.sh:62`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/local-test.sh
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 artifacts omit expected sources

When all configured --extract patterns match no tracefile records, LCOV_IGN suppresses the unused error, and the scripts do not verify the extraction result, so collection succeeds with empty or incomplete coverage artifacts.

Check that extraction selects the intended source records and fail collection when it does not.

Also at tests/qmake-lcov-test.sh:26, tests/test-prj-running.sh:62.

Prompt for AI agents
In `tests/local-test.sh` at line 34:

**Coverage artifacts omit expected sources**

When all configured `--extract` patterns match no tracefile records, `LCOV_IGN` suppresses the `unused` error, and the scripts do not verify the extraction result, so collection succeeds with empty or incomplete coverage artifacts.

Check that extraction selects the intended source records and fail collection when it does not.

Also at `tests/qmake-lcov-test.sh:26`, `tests/test-prj-running.sh:62`.

Comment thread tests/local-test.sh
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 · Test code inflates project coverage

When test source paths do not match the removal glob, LCOV_IGN also reaches each lcov --remove command, suppressing its unused error; test records remain in coverage.info, so the report counts test code as project coverage.

Do not pass the unused ignore setting to lcov --remove, so unmatched exclusion patterns fail rather than leave test records in the report.

Also at tests/qmake-lcov-test.sh:26, tests/test-prj-running.sh:62.

Prompt for AI agents
In `tests/local-test.sh` at line 34:

**Test code inflates project coverage**

When test source paths do not match the removal glob, `LCOV_IGN` also reaches each `lcov --remove` command, suppressing its `unused` error; test records remain in `coverage.info`, so the report counts test code as project coverage.

Do not pass the `unused` ignore setting to `lcov --remove`, so unmatched exclusion patterns fail rather than leave test records in the report.

Also at `tests/qmake-lcov-test.sh:26`, `tests/test-prj-running.sh:62`.

CI 镜像 lcov 2.x 对 --extract 未命中的 include pattern 直接报 ERROR (unused),
1.x 仅警告;脚本 set -e 中断导致 ut-summary.json 未产出,流水线覆盖率记 0。
统一在 lcov 2.x 版本门控的 --ignore-errors 中追加 unused。

PMS: TASK-398635
Log: CI 上 lcov 2.x extract pattern 未命中即致命,ut-summary.json 缺失
Influence: 仅影响 UT 流水线覆盖率采集脚本,lcov 1.x 行为不变
@add-uos
add-uos force-pushed the fix-ut-lcov-unused branch from 8e3895f to a5efa87 Compare December 1, 2026 06:44
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos

add-uos commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit 6b02865 into linuxdeepin:master Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants