Skip to content

Fix/enable orphan unit tests - #891

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/enable-orphan-unit-tests
Aug 3, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/enable-orphan-unit-tests

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Investigation of 9 remaining orphan test files (not compiled by the test build) via code graph + build attempts. Findings:

Enabled (4 new test cases, 1487 -> 1491):

  • widgets/ut_colorbutton.h: fix include path (../widgets/ ->
    ../../src/widgets/), adds ColorButtonTest
  • gstrecord/ut_gstrecordx.h: add -lgobject-2.0 to LIBS, adds GstRecordXTest (hardware cases already skipped via SKIP_TESTS)

Deleted (7 dead test files, -629 lines):

  • utils/ut_toolshape.h: empty fixture with 0 TEST_F cases
  • dbusinterface/ut_drawinterface.h: wrong include path + depends on external deepin-draw DBus + system("killall")
  • widgets/ut_majtoolbar.h / widgets/ut_subtoolbar.h / ut_record_option_panel.h / utils/ut_screenutils.h / ut_process_tree_ext.h: root cause is main project builds on Qt5 while tests use Qt6; ConfigSettings was refactored value()-> getValue() but these source files retain active calls to the old API (they only "compiled" because the test build never compiled them). The corresponding source classes (MajToolBar, SubToolBar, RecordOptionPanel, ScreenUtils, ProcessTree) have zero external references in the project — legacy dead code.

对9个剩余孤儿测试通过代码图谱+编译尝试分析:启用ut_colorbutton(修
复include路径)和ut_gstrecordx(加-lgobject-2.0链接),新增4个测试 用例(1487->1491);删除7个死代码测试文件。根因是主项目用Qt5构建、
测试用Qt6,ConfigSettings重构value()->getValue()后5个源文件仍残留 旧API调用,对应类在项目中零外部引用,属历史遗留死代码。

Log: 启用有效孤儿测试并删除死代码测试
Influence: 新增4个测试用例(1491总计),删除7个无效孤儿测试文件(-629行),清理test_all_interfaces.h暂缓注释。

Summary by Sourcery

Enable previously orphaned unit tests for ColorButton and GstRecordX while removing obsolete test files and updating test build links.

New Features:

  • Add ColorButtonTest and GstRecordXTest to the unified test interface and build configuration.

Bug Fixes:

  • Fix ColorButton test include path to reference the actual widget source location.
  • Add missing gobject-2.0 library linkage to the screenshot recorder test binary to satisfy GstRecordX dependencies.

Enhancements:

  • Remove legacy, unreferenced test fixtures and associated source dependencies that no longer build against the current ConfigSettings API.

Build:

  • Update ut_screen_shot_recorder test project to link against gobject-2.0 and to compile the ColorButton widget sources for the new tests.

Tests:

  • Wire previously uncompiled orphan test headers into test_all_interfaces and the test project, increasing the active unit test count.
  • Clean up test_all_interfaces documentation comments to note removed dead tests and clarify the status of deleted orphan test files.

@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

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

Reviewer's Guide

Enables two previously orphaned test suites by fixing includes and linking, wires their headers into the main test harness, and deletes seven dead orphan test files whose corresponding production classes are unused and API-drifted.

File-Level Changes

Change Details Files
Enable previously orphaned ColorButton test by fixing include paths and wiring it into the ut_screen_shot_recorder test project.
  • Add widgets/ut_colorbutton.h to HEADERS and test_all_interfaces.h so it is compiled and executed
  • Fix ut_colorbutton.h include from a local widgets path to the src/widgets colorbutton header
  • Add colorbutton.h to HEADERS and colorbutton.cpp to SOURCES in ut_screen_shot_recorder.pro to ensure proper moc and linking
tests/ut_screen_shot_recorder/ut_screen_shot_recorder.pro
tests/ut_screen_shot_recorder/test_all_interfaces.h
tests/ut_screen_shot_recorder/widgets/ut_colorbutton.h
Enable previously orphaned GstRecordX test by fixing link flags and registering the test header in the harness.
  • Append -lgobject-2.0 to LIBS in ut_screen_shot_recorder.pro so gstrecordx tests can link successfully
  • Add gstrecord/ut_gstrecordx.h to HEADERS and test_all_interfaces.h so the test is built and run
tests/ut_screen_shot_recorder/ut_screen_shot_recorder.pro
tests/ut_screen_shot_recorder/test_all_interfaces.h
Remove seven dead orphan test headers whose corresponding source classes are unused legacy code and no longer build cleanly.
  • Delete dbusinterface/ut_drawinterface.h and document its removal in test_all_interfaces.h comments
  • Delete ut_process_tree_ext.h, ut_record_option_panel.h, utils/ut_screenutils.h, utils/ut_toolshape.h, widgets/ut_majtoolbar.h, widgets/ut_subtoolbar.h as dead tests
  • Annotate in test_all_interfaces.h that the removed tests targeted legacy classes with ConfigSettings API drift and no external references
tests/ut_screen_shot_recorder/test_all_interfaces.h
tests/ut_screen_shot_recorder/dbusinterface/ut_drawinterface.h
tests/ut_screen_shot_recorder/ut_process_tree_ext.h
tests/ut_screen_shot_recorder/ut_record_option_panel.h
tests/ut_screen_shot_recorder/utils/ut_screenutils.h
tests/ut_screen_shot_recorder/utils/ut_toolshape.h
tests/ut_screen_shot_recorder/widgets/ut_majtoolbar.h
tests/ut_screen_shot_recorder/widgets/ut_subtoolbar.h

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 left some high level feedback:

  • Instead of hardcoding -lgobject-2.0 into LIBS, consider wiring it through the same pkg-config or shared library configuration mechanism used for the rest of the GLib stack so the test project stays portable across different toolchains/platforms.
  • The direct ../../src/widgets/colorbutton.{h,cpp} paths in the test project duplicate source locations; if possible, refactor to reuse an existing shared .pri/.pro fragment or library target so that future moves/renames of colorbutton don’t require manual updates in the test build.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of hardcoding `-lgobject-2.0` into `LIBS`, consider wiring it through the same pkg-config or shared library configuration mechanism used for the rest of the GLib stack so the test project stays portable across different toolchains/platforms.
- The direct `../../src/widgets/colorbutton.{h,cpp}` paths in the test project duplicate source locations; if possible, refactor to reuse an existing shared .pri/.pro fragment or library target so that future moves/renames of `colorbutton` don’t require manual updates in the test build.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Investigation of 9 remaining orphan test files (not compiled by the
test build) via code graph + build attempts. Findings:

Enabled (4 new test cases, 1487 -> 1491):
- widgets/ut_colorbutton.h: fix include path (../widgets/ ->
  ../../src/widgets/), adds ColorButtonTest
- gstrecord/ut_gstrecordx.h: add -lgobject-2.0 to LIBS, adds
  GstRecordXTest (hardware cases already skipped via SKIP_TESTS)

Deleted (7 dead test files, -629 lines):
- utils/ut_toolshape.h: empty fixture with 0 TEST_F cases
- dbusinterface/ut_drawinterface.h: wrong include path + depends on
  external deepin-draw DBus + system("killall")
- widgets/ut_majtoolbar.h / widgets/ut_subtoolbar.h /
  ut_record_option_panel.h / utils/ut_screenutils.h /
  ut_process_tree_ext.h: root cause is main project builds on Qt5
  while tests use Qt6; ConfigSettings was refactored value()->
  getValue() but these source files retain active calls to the old
  API (they only "compiled" because the test build never compiled
  them). The corresponding source classes (MajToolBar, SubToolBar,
  RecordOptionPanel, ScreenUtils, ProcessTree) have zero external
  references in the project — legacy dead code.

对9个剩余孤儿测试通过代码图谱+编译尝试分析:启用ut_colorbutton(修
复include路径)和ut_gstrecordx(加-lgobject-2.0链接),新增4个测试
用例(1487->1491);删除7个死代码测试文件。根因是主项目用Qt5构建、
测试用Qt6,ConfigSettings重构value()->getValue()后5个源文件仍残留
旧API调用,对应类在项目中零外部引用,属历史遗留死代码。

Log: 启用有效孤儿测试并删除死代码测试
Influence: 新增4个测试用例(1491总计),删除7个无效孤儿测试文件(-629行),清理test_all_interfaces.h暂缓注释。
@pengfeixx
pengfeixx force-pushed the fix/enable-orphan-unit-tests branch from 8dc7ae8 to 628021e Compare August 3, 2026 07:52
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码清理了历史遗留的死代码测试并修复了编译路径问题,整体质量优秀
逻辑正确且无任何安全漏洞,不扣分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

修复了 ut_colorbutton.h 中错误的相对路径引用,将 ../widgets/colorbutton.h 修正为 ../../src/widgets/colorbutton.h,与 .pro 文件中的源文件路径保持一致,解决了编译期找不到头文件的问题。在 ut_screen_shot_recorder.pro 中补全了 colorbutton.cpp 和 colorbutton.h 的编译条目,并添加了 -lgobject-2.0 链接依赖以解决 GstRecordX 测试的链接问题。删除了依赖已漂移 API 的死代码测试,避免了编译失败。
建议:无

  • 2.代码质量(良好)✓

在 test_all_interfaces.h 中增加了详尽的注释,明确说明了删除孤儿测试的原因是“源码类在主项目中已无任何外部引用,属历史遗留死代码,且源码自身存在 API 漂移”,这为后续维护提供了良好的上下文。清理无用代码有效降低了代码库的维护负担。
建议:无

  • 3.代码性能(无性能问题)✓

本次提交仅涉及测试代码的增删改以及 qmake 构建文件的配置调整,不涉及生产代码的运行时逻辑,因此不会引入任何性能开销或资源泄漏问题。
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 1 个,持平 0 个
本次修改未引入任何安全漏洞,反而通过删除 ut_drawinterface.h 移除了一个在测试清理阶段调用 system("killall deepin-draw") 的潜在命令执行风险点,提升了整体安全性。
建议:无

■ 【改进建议代码示例】

// 当前代码修改已足够规范,无需额外改进示例
// 路径修复已准确到位:
#include "../../src/widgets/colorbutton.h"

@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 7bd2f62 into linuxdeepin:master Aug 3, 2026
9 checks passed
@pengfeixx
pengfeixx deleted the fix/enable-orphan-unit-tests branch August 3, 2026 07:57
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