Skip to content

fix: add missing src include dir to UT targets - #707

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/ut-missing-src-include-dir
Oct 30, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/ut-missing-src-include-dir

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • UT 集群上构建在 19% 处中断:test_markdownimagehandler(测试 TU 直接 include markdownview.cpp)和 test_common2(编译被测源码 text_file_saver.cpp)均报 fatal error: ddlog.h: 没有那个文件或目录。
  • 根因:这两个 UT 目标的 target_include_directories 缺少 ${CMAKE_SOURCE_DIR}/src,而 ddlog.h 位于 src/ 下,导致 #include "ddlog.h" 无法解析。
  • make 中断后约 40 个测试目标未被编译,UT 统计只剩 8 个已编完的二进制共 128 条用例(行覆盖率跌至 19.4%),且整个任务仍以 exit 0 结束,CI 显示"全绿"。

Changes

  • tests/editor_markdown/CMakeLists.txt:md_add_test() 公共 include 路径增加 ${CMAKE_SOURCE_DIR}/src,同时覆盖同样直接编译 markdownview.cpp 的 test_markdownview。
  • tests/common2/CMakeLists.txt:test_common2 增加 ${CMAKE_SOURCE_DIR}/src(该目标中的 config.cpp 同样 include 了 ddlog.h)。

Testing

  • BUILD_TESTS=ON 本地重新编译 test_common2 / test_markdownimagehandler / test_markdownview,均编译通过
  • 运行三个目标:test_common2 147 条、test_markdownimagehandler 8 条、test_markdownview 23 条,全部 PASSED
  • CI 流水线 UT 统计用例数从 128 条恢复至完整数量

Summary by Sourcery

Restore unit-test builds by adding the project source directory to the affected test targets’ include paths.

Bug Fixes:

  • Fix unit-test targets that failed to compile because the source directory containing ddlog.h was missing from their include paths.

Build:

  • Update common2 and editor markdown test targets to include the project source directory during compilation.

Tests:

  • Restore compilation and execution of the affected common2 and editor markdown unit-test targets.

1. test_common2 and md_add_test targets failed to find ddlog.h
2. Add ${CMAKE_SOURCE_DIR}/src to their include directories
3. Restores ~40 test targets aborted mid-build on UT cluster

Log: No user-facing changes

Influence:
1. Rebuild with BUILD_TESTS=ON and confirm all UT targets compile
2. Run test_common2, test_markdownimagehandler and test_markdownview
3. Check CI UT summary case count restored from 128 to full set

fix: 为UT目标补充缺失的src头文件搜索路径

1. test_common2与md_add_test目标编译时找不到ddlog.h而中断
2. 在其include路径中补充${CMAKE_SOURCE_DIR}/src
3. 恢复UT集群上因编译中断而丢失的约40个测试目标

Log: 无用户可见变化

Influence:
1. 开启BUILD_TESTS=ON重新编译,确认全部UT目标可编译
2. 运行test_common2、test_markdownimagehandler、test_markdownview
3. 检查CI的UT统计用例数从128条恢复至完整数量
@sourcery-ai

sourcery-ai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes incomplete UT builds by adding the missing source-root include directory to the markdown test helper and test_common2 target, allowing sources that include ddlog.h to compile and preventing silent omission of subsequent test targets.

File-Level Changes

Change Details Files
Restore the source-root include path for affected unit-test targets so test translation units can resolve ddlog.h.
  • Add ${CMAKE_SOURCE_DIR}/src to the shared include paths generated by md_add_test(), covering markdown image-handler and markdown-view tests.
  • Add ${CMAKE_SOURCE_DIR}/src to test_common2’s private include directories.
tests/editor_markdown/CMakeLists.txt
tests/common2/CMakeLists.txt

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 reviewed your changes and they look great!


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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为构建修复,在两个测试目标的 CMakeLists.txt 中添加缺失的 ${CMAKE_SOURCE_DIR}/src 包含目录。变更极简(2行新增),语法正确、逻辑清晰,无安全漏洞,无性能问题,与 commit 目的完全匹配。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例


本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, pengfeixx

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

@pengfeixx

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 908f542 into linuxdeepin:master Oct 30, 2026
17 checks passed
@pengfeixx
pengfeixx deleted the fix/ut-missing-src-include-dir branch October 30, 2026 07:08
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