Skip to content

refactor(test): move all sub-project tests to top-level test directory - #975

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:refactor-move-tests-to-top-level-test
Nov 12, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:refactor-move-tests-to-top-level-test

Conversation

@add-uos

@add-uos add-uos commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

变更说明

将 deepin-devicemanager/tests 与 deepin-devicemanager-server/tests 外移至仓库根目录统一 test/ 树,由根 CMakeLists 在覆盖率开关(CMAKE_COVERAGE_ARG_ON)下挂载,非覆盖率构建不受影响。

主要内容

  • 测试目录外移:196 个测试文件通过 rename 迁移至 test/{deepin-devicemanager,deepin-devicemanager-server}/,git 历史完整保留
  • 构建接线:根 CMakeLists 新增 add_subdirectory(test/...);两个子项目 CMakeLists 移除原 add_subdirectory(./tests)
  • 目标名固定:外移后 PROJECT_NAME 作用域变化,测试目标名硬编码为 deepin-devicemanager-test / deepin-devicemanager-server-test 等 4 个,避免客户端/服务端目标名冲突
  • 相对引用修复:修复 2 处因外移失效的 ../../../ 相对 include
  • 继承依赖显式化:客户端测试原先从父作用域继承的 include 路径与宏定义(DISABLE_DRIVER、QT_MESSAGELOGCONTEXT、QApt、DDLog)改为显式声明
  • 统一测试入口:test/test-prj-running.sh 改为从仓库根构建并运行全部 4 个 gtest 二进制(client/server/control/customgpuinfo,其中 customgpuinfo-test 此前从未被执行过),输出 build-ut/(XML 报告 + lcov HTML + ut-summary.json)
  • 覆盖率过滤调整:'*/tests/*' → '*/test/*',避免外移后的测试源码经 '*/src/*' 误入项目覆盖率统计
  • 清理:删除已失效的 run-ut.sh(其 test_* 二进制发现模式从未匹配到实际目标);gen-ut-summary.py 去重为单份

自测结果

  • 4 个测试二进制共 3341/3341 用例全部通过
  • 行覆盖率 91.30%,函数覆盖率 96.10%,coverage.info 中测试树条目为 0

Summary by Sourcery

Centralize sub-project unit tests under the top-level test tree and provide unified coverage-build execution and reporting.

Enhancements:

  • Centralize client and server unit tests under the top-level test/ directory with explicit build dependencies and stable test target names.
  • Unify coverage test execution and reporting for all four test binaries, including customgpuinfo coverage and filtering for relocated test sources.

Build:

  • Enable top-level test integration only for coverage builds and remove obsolete per-project test wiring and scripts.

Tests:

  • Relocate the existing client and server test suites while preserving their contents and update paths and references for the new layout.

Chores:

  • Remove obsolete duplicate test utilities and update project metadata for the relocated test tree.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 hours and 33 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "deepin-devicemanager-server/tests/run-ut.sh": {
            "a": [
                "export QT_QPA_PLATFORM=${QT_QPA_PLATFORM:-offscreen}",
                "export ASAN_OPTIONS=${ASAN_OPTIONS:-detect_leaks=1}",
                "    export LSAN_OPTIONS=suppressions=\"$SCRIPT_DIR/lsan_suppressions.txt\"",
                "    export projectdir=\"$PROJECT_ROOT\"",
                "    export builddir=\"build-${TEST_DIR}\"",
                "    export reportdir=\"build-${TEST_DIR}\"",
                "    export GTEST_XML_DIR=\"$GTEST_XML_DIR\"",
                "    export COVERAGE_INFO=\"$BUILD_DIR/coverage.info\""
            ]
        }
    }
}

Consolidate deepin-devicemanager/tests and deepin-devicemanager-server/
tests into a unified top-level test/ tree, wired from the root
CMakeLists under the coverage guard. Hardcode test target names, fix
escaping relative includes, and declare previously inherited include
dirs in the client test build.

Adapt test-prj-running.sh to build and run all four gtest binaries
(client/server/control/customgpuinfo) and align lcov filters with the
new test/ layout. Drop the stale server run-ut.sh runner.

将两个子项目的 tests/ 外移至顶层统一 test/ 目录,由根 CMakeLists 在
覆盖率开关下挂载;固定测试目标名,修复外移后的相对引用,并显式声明
原先继承的 include 路径;改造 test-prj-running.sh 统一运行全部 4 个
gtest 二进制,覆盖率过滤规则同步调整;删除已失效的 run-ut.sh。

Log: 子项目测试外移至顶层test目录并统一测试入口脚本
Influence: 单测代码位置与构建接线变化;test/test-prj-running.sh 成为
唯一测试入口,覆盖率统计不再包含测试源码本身(实测 3341 用例全通过,
行覆盖率 91.30%)。
@add-uos
add-uos force-pushed the refactor-move-tests-to-top-level-test branch from 61e4481 to 509fba5 Compare November 12, 2026 08:55
@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "deepin-devicemanager-server/tests/run-ut.sh": {
            "a": [
                "export QT_QPA_PLATFORM=${QT_QPA_PLATFORM:-offscreen}",
                "export ASAN_OPTIONS=${ASAN_OPTIONS:-detect_leaks=1}",
                "    export LSAN_OPTIONS=suppressions=\"$SCRIPT_DIR/lsan_suppressions.txt\"",
                "    export projectdir=\"$PROJECT_ROOT\"",
                "    export builddir=\"build-${TEST_DIR}\"",
                "    export reportdir=\"build-${TEST_DIR}\"",
                "    export GTEST_XML_DIR=\"$GTEST_XML_DIR\"",
                "    export COVERAGE_INFO=\"$BUILD_DIR/coverage.info\""
            ]
        }
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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-uos

add-uos commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 0e990c1 into linuxdeepin:master Nov 12, 2026
15 of 20 checks passed
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