Skip to content

test(ci): update coverage filter and register test targets - #767

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ci-infra
Jul 15, 2026
Merged

test(ci): update coverage filter and register test targets#767
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:test/ci-infra

Conversation

@pengfeixx

Copy link
Copy Markdown
Contributor

Exclude 0%-coverage plugin entry points from lcov filter, register singleton and transfer_helper test targets, add session_core test sources to coop_gui build.

更新lcov覆盖率过滤规则排除不可测插件入口文件,注册singleton和
transfer_helper测试目标,将session_core测试源加入coop_gui构建。

Log: 更新覆盖率脚本和测试目标注册
Influence: 修改覆盖率过滤规则和CMake配置,影响测试构建和报告生成。

@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, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@github-actions

Copy link
Copy Markdown
  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "tests/singleton/singleapplication_test.cpp": [
        {
            "line": "    QString key = \"ut-single-main\";",
            "line_number": 75,
            "rule": "S106",
            "reason": "Var naming | 4ec0ad194f"
        },
        {
            "line": "    QString key = \"ut-single-main\";",
            "line_number": 81,
            "rule": "S106",
            "reason": "Var naming | 4ec0ad194f"
        }
    ]
}

Exclude 0%-coverage plugin entry points from lcov filter, register
singleton and transfer_helper test targets, add session_core test
sources to coop_gui build.

更新lcov覆盖率过滤规则排除不可测插件入口文件,注册singleton和
transfer_helper测试目标,将session_core测试源加入coop_gui构建。

Log: 更新覆盖率脚本和测试目标注册
Influence: 修改覆盖率过滤规则和CMake配置,影响测试构建和报告生成。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码新增了针对核心模块的全面单元测试,覆盖了设备发现、传输能力判断和单例进程锁等关键逻辑
测试用例设计合理,边界条件覆盖充分,代码质量优秀,无安全漏洞

■ 【详细分析】

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

测试代码使用 GTest 和 Qt 测试框架,语法正确。DiscoverDeepTestTransferHelperCtTestSingleAppTest 中的测试用例逻辑清晰,正确验证了目标函数的行为。tests/transfer_helper/main.cpp 中通过弱符号 __gcov_dump__gcov_flush 确保覆盖率落盘的处理逻辑正确,有效解决了 _exit(0) 导致覆盖率丢失的问题。
潜在问题:无
建议:无

  • 2.代码质量(优秀)✓

测试命名规范,如 UpdateDeviceStateDisconnectedTransableOnlyConnectedModeNotConnected 等,清晰表达了测试意图。使用了 Test Fixture (DiscoverDeepTest) 管理公共的初始化和清理逻辑,减少了代码重复。注释充分,特别是在 tests/singleton/CMakeLists.txtmain.cpp 中对 _exit(0) 特殊处理的说明,有助于后续维护。mainwindow_stub.cpp 桩代码有效隔离了 GUI 依赖。
潜在问题:无
建议:无

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

作为单元测试代码,执行效率高,没有不必要的等待或复杂计算。QSignalSpy 的使用正确且轻量,不会对测试性能产生负面影响。
潜在问题:无
建议:无

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次提交为纯单元测试代码,未引入任何外部输入处理或危险操作,不存在安全风险。测试中使用的硬编码 IP 和字符串仅用于测试环境,不会泄露敏感信息。

  • 建议:无

■ 【改进建议代码示例】

// 当前代码质量已经很高,无需修复。
// 以下是一个可选的微小改进示例,在 transferhelper_ct_test.cpp 中提取重复的 JSON 构建逻辑,
// 虽然当前已通过 makeDevJson 函数实现,但可以进一步将其提取为共享的测试工具类,
// 以便在 session_core_deep_test.cpp 和 transferhelper_ct_test.cpp 之间复用。

// tests/common/test_json_helper.h
#pragma once
#include <QString>
#include <QJsonObject>
#include <QJsonDocument>
#include <QVariantMap>
#include "global_defines.h"

namespace test_utils {
    static QString makeDevJson(const QString &ip, const QString &name,
                               int transMode = 0, int discoveryMode = 0)
    {
        QVariantMap map;
        map.insert(AppSettings::IPAddress, ip);
        map.insert(AppSettings::DeviceNameKey, name);
        map.insert(AppSettings::DiscoveryModeKey, discoveryMode);
        map.insert(AppSettings::TransferModeKey, transMode);
        map.insert(AppSettings::LinkDirectionKey, 0);
        map.insert(AppSettings::ClipboardShareKey, false);
        map.insert(AppSettings::PeripheralShareKey, false);
        map.insert(AppSettings::CooperationEnabled, true);
        map.insert(AppSettings::OSType, 0);
        return QString::fromUtf8(
            QJsonDocument(QJsonObject::fromVariantMap(map)).toJson(QJsonDocument::Compact));
    }
}

@github-actions

Copy link
Copy Markdown
  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "tests/singleton/singleapplication_test.cpp": [
        {
            "line": "    QString key = \"ut-single-main\";",
            "line_number": 75,
            "rule": "S106",
            "reason": "Var naming | 4ec0ad194f"
        },
        {
            "line": "    QString key = \"ut-single-main\";",
            "line_number": 81,
            "rule": "S106",
            "reason": "Var naming | 4ec0ad194f"
        }
    ]
}

@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

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 332ade0 into linuxdeepin:master Jul 15, 2026
20 of 22 checks passed
@pengfeixx
pengfeixx deleted the test/ci-infra branch July 15, 2026 02:30
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