Skip to content

test: add test build infra and daemon/start-manager tests - #560

Merged
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ut-build-infra-daemon-startmanager
Sep 4, 2026
Merged

test: add test build infra and daemon/start-manager tests#560
pengfeixx merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ut-build-infra-daemon-startmanager

Conversation

@pengfeixx

Copy link
Copy Markdown
Contributor

内容

新增单元测试构建基础设施(UnitTestUtils.cmake、BUILD_TESTS 构建开关、运行脚本、README),以及 daemon(含 dbus)、startmanager 模块的 GTest 单元测试,共 20 个文件。

说明

  • 基于 master 独立拉出,可独立评审与合并
  • 仅新增测试代码与构建脚本,不改动编辑器本体功能

@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.

Sorry @pengfeixx, your pull request is larger than the review limit of 150,000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 95 分,大于 70 分通过阈值。本次 PR 新增单元测试构建基础设施和 daemon/startmanager 模块的 GTest 单元测试,代码质量高,文档完善,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. tests/CMakeLists.txt:219 - add_subdirectory 引用多个可能不存在的子目录,若目录缺失会导致构建失败

建议: 建议对不确定存在的子目录使用 add_subdirectory_if_exists(UnitTestUtils.cmake 已提供该函数),或在 PR 中说明这些目录已存在于 master 分支


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. tests/daemon_ut/ut_setcodec_compat.h:11 - #define setCodec(a) 宏定义过于宽泛,参数被忽略,存在意外包含风险
  2. tests/test-prj-running.sh:21 - rm -rf $builddir 未加引号,建议改为 rm -rf "$builddir"

建议: 1. ut_setcodec_compat.h 宏建议改为更安全的方式,如在宏名中添加前缀避免冲突,或使用内联函数替代
2. test-prj-running.sh 中的 rm -rf 命令建议加引号:rm -rf "$builddir" 和 rm -rf "$reportdir"


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. tests/startmanager/test_startmanager.cpp:2897 - processEventsFor 使用 busy-wait 循环,效率不高但测试场景可接受

建议: 测试场景下 busy-wait 可接受,若需优化可考虑使用 QSignalSpy::wait 或 QTimer::singleShot 替代


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无安全风险,安全合规


💡 改进建议代码示例

// ut_setcodec_compat.h 改进建议:使用更安全的宏名
#pragma once

#include <QStringConverter>

// 使用带前缀的宏名,避免与其他 setCodec 调用冲突
#define UT_SETCODEC_COMPAT(a) setEncoding(QStringConverter::Utf8)

// test-prj-running.sh 改进建议:加引号保护
# rm -rf "$builddir"
# rm -rf "$reportdir"

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

@pengfeixx
pengfeixx force-pushed the test/ut-build-infra-daemon-startmanager branch 2 times, most recently from 9fc3dd7 to a5d8517 Compare September 4, 2026 07:36
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
  • 检测到敏感词unset, export变动
详情
    {
    "unset": {
        "tests/startmanager/test_startmanager_drag.cpp": {
            "b": [
                "        qunsetenv(\"XDG_CONFIG_HOME\");",
                "        qunsetenv(\"XDG_DATA_HOME\");"
            ]
        }
    },
    "export": {
        "tests/test-prj-running.sh": {
            "b": [
                "export QT_QPA_PLATFORM=offscreen"
            ]
        }
    }
}

@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

Add unit test build infrastructure (UnitTestUtils.cmake, run scripts,
BUILD_TESTS option, README) and GTest suites for daemon, dbus and
start manager modules.

新增单元测试构建基础设施(UnitTestUtils.cmake、运行脚本、BUILD_TESTS
开关、README),以及 daemon、dbus、startmanager 模块的 GTest 单元测试。

Log: 新增测试构建基础设施及 daemon/startmanager 单元测试
Influence: 仅新增测试与构建脚本,不影响编辑器本体功能。
@pengfeixx
pengfeixx force-pushed the test/ut-build-infra-daemon-startmanager branch from a5d8517 to 04c7aca Compare September 4, 2026 08:39
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
  • 检测到敏感词unset, export变动
详情
    {
    "unset": {
        "tests/startmanager/test_startmanager_drag.cpp": {
            "b": [
                "        qunsetenv(\"XDG_CONFIG_HOME\");",
                "        qunsetenv(\"XDG_DATA_HOME\");"
            ]
        }
    },
    "export": {
        "tests/test-prj-running.sh": {
            "b": [
                "export QT_QPA_PLATFORM=offscreen"
            ]
        }
    }
}

@pengfeixx
pengfeixx merged commit 29c975c into linuxdeepin:master Sep 4, 2026
15 of 17 checks passed
@pengfeixx
pengfeixx deleted the test/ut-build-infra-daemon-startmanager branch September 4, 2026 08:46
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