Skip to content

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Nov 3, 2025

此提交使 CMake 可以通过 gtest 提供的支持发现单元测试,旨在让 IDE 等工具可以更方便的识别并运行单个单元测试而不是每次都跑完整的一组测试。

Summary by Sourcery

Enhancements:

  • Include the GoogleTest CMake module and invoke gtest_discover_tests in CMakeLists for taskmanager panel tests to auto-register each test case with CTest.

@BLumia BLumia requested review from 18202781743 and wjyrich November 3, 2025 12:16
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 3, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR enhances the CMake configuration to integrate GoogleTest's discovery mechanism, allowing ctest (and IDEs) to detect and run individual gtest unit tests automatically.

File-Level Changes

Change Details Files
Enable ctest to auto-discover gtest unit tests via CMake integration
  • Include the GoogleTest CMake module
  • Invoke gtest_discover_tests for rolecombinemodel_tests
  • Invoke gtest_discover_tests for rolegroupmodel_tests
tests/panels/dock/taskmanager/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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


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.

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个CMakeLists.txt的变更进行审查:

  1. 语法逻辑审查:
  • 语法正确,没有明显的语法错误
  • 使用了标准的CMake命令和变量
  • 变更内容是合法的CMake语法
  1. 代码质量改进:
  • add_test改为gtest_discover_tests是一个很好的改进
  • gtest_discover_tests可以自动发现测试用例,比手动指定更灵活
  • 添加了include(GoogleTest)是必要的,因为使用了gtest_discover_tests
  1. 性能考虑:
  • 这个变更不会影响运行时性能
  • 在构建时可能会有轻微的开销,因为gtest_discover_tests需要扫描测试文件
  • 但这个开销是值得的,因为它提供了更好的测试管理
  1. 安全性考虑:
  • 没有直接的安全影响
  • 使用gtest_discover_tests可能会更安全,因为它可以确保所有测试都被发现和运行
  1. 建议和改进:
  • 变更本身是好的,但建议在文件开头添加注释说明为什么使用gtest_discover_tests
  • 可以考虑添加版本检查,确保GoogleTest模块的版本兼容性
  • 建议保持一致的代码风格,比如删除了最后的空行,建议保留
  1. 其他建议:
# 添加版本检查
if(CMAKE_VERSION VERSION_LESS "3.10")
    message(FATAL_ERROR "CMake 3.10 or higher is required for gtest_discover_tests")
endif()

# 添加注释说明
# Use gtest_discover_tests for automatic test discovery instead of manually specifying tests
include(GoogleTest)

总的来说,这个变更是积极的,它提高了测试的可维护性和自动化程度。建议可以采纳,但最好添加一些注释和版本检查来提高代码的可读性和健壮性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@BLumia BLumia merged commit 6d51465 into linuxdeepin:master Nov 4, 2025
10 of 11 checks passed
@BLumia BLumia deleted the gtest branch November 4, 2025 05:58
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