Repository navigation
test: 补充控制中心 12 个核心单元的全量单元测试 (DDE-104) - #3519
Conversation
|
Hi @MyLeeJiEun. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideThis PR adds 334 GoogleTest cases across 12 previously uncovered Control Center units, validates Qt model/object behavior and utility edge cases without changing production sources, and wires the tests into the build with ICU/Qt dependencies plus optional lcov HTML coverage reporting; the reported result is 331 passed, 3 skipped, and no failures. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/CMakeLists.txt" line_range="76-77" />
<code_context>
+#(GNU: -fprofile-arcs -ftest-coverage;Clang: -fprofile-instr-generate -ftest-coverage)。
+# 这里将其应用到 unit-test target,使被测源与测试源都被插桩。
+if(UNITTEST AND DEFINED UT_COMPILER)
+ target_compile_options(${BIN_NAME} PRIVATE ${UT_COMPILER})
+ target_link_options(${BIN_NAME} PRIVATE ${UT_COMPILER})
+endif()
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The Clang branch supplies `-fprofile-instr-generate -ftest-coverage`, which produces LLVM profiling data, but the coverage target always invokes `lcov --capture`, which expects gcov-compatible coverage data. On Clang builds the `coverage` target therefore fails or produces no usable report.
**Triggers:** When the project is configured with Clang and the `coverage` target is built.
**Suggested fix:** Use LLVM's `llvm-profdata`/`llvm-cov export` pipeline for Clang, or restrict the lcov target to GNU instrumentation and provide a separate Clang coverage target.
</issue_to_address>
### Comment 2
<location path="tests/CMakeLists.txt" line_range="86-111" />
<code_context>
+find_program(LCOV_BIN lcov)
</code_context>
<issue_to_address>
**nitpick (bug_risk):** When either `lcov` or `genhtml` is unavailable, `_coverage_report_cmds` remains empty but the `coverage` target is still created and runs only CTest. The target then succeeds without generating the coverage report promised by its name and comments.
**Triggers:** When the build environment lacks `lcov` or `genhtml`.
**Suggested fix:** Fail configuration or the target explicitly when the coverage tools are missing, or rename the fallback target so it does not claim to generate coverage.
</issue_to_address>| find_program(LCOV_BIN lcov) | ||
| find_program(GENHTML_BIN genhtml) | ||
| set(_coverage_report_cmds "") | ||
| if(LCOV_BIN AND GENHTML_BIN) | ||
| set(_coverage_report_cmds | ||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/coverage_report" | ||
| COMMAND ${LCOV_BIN} --capture --directory "${CMAKE_BINARY_DIR}" | ||
| --rc lcov_branch_coverage=1 | ||
| --output-file "${CMAKE_BINARY_DIR}/coverage.info" | ||
| COMMAND ${LCOV_BIN} --extract "${CMAKE_BINARY_DIR}/coverage.info" | ||
| --rc lcov_branch_coverage=1 | ||
| "${PROJECT_SOURCE_DIR}/src/shared-utils/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-keyboard/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-datetime/operation/timezoneMap/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-defaultapp/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-personalization/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-mouse/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-bluetooth/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-sound/operation/*" | ||
| "${PROJECT_SOURCE_DIR}/src/plugin-dock/operation/*" | ||
| --output-file "${CMAKE_BINARY_DIR}/coverage_filtered.info" | ||
| COMMAND ${GENHTML_BIN} "${CMAKE_BINARY_DIR}/coverage_filtered.info" | ||
| --branch-coverage | ||
| --output-directory "${CMAKE_BINARY_DIR}/coverage_report" | ||
| ) | ||
| endif() |
There was a problem hiding this comment.
nitpick (bug_risk): When either lcov or genhtml is unavailable, _coverage_report_cmds remains empty but the coverage target is still created and runs only CTest. The target then succeeds without generating the coverage report promised by its name and comments.
Triggers: When the build environment lacks lcov or genhtml.
Suggested fix: Fail configuration or the target explicitly when the coverage tools are missing, or rename the fallback target so it does not claim to generate coverage.
cc7aab4 to
aa7b4d0
Compare
|
TAG Bot New tag: 6.1.109 |
aa7b4d0 to
f83ec69
Compare
|
TAG Bot New tag: 6.1.110 |
|
TAG Bot New tag: 6.1.111 |
f83ec69 to
3cd7fb3
Compare
|
TAG Bot New tag: 6.1.112 |
|
TAG Bot New tag: 6.1.113 |
1. 为 keyboard、defaultapp、sound、datetime、personalization、mouse、 bluetooth、dock 及 shared-utils 补充 12 组单元测试,共 334 个用例 2. 测试按归属放到 src/<module>/tests/,由各模块 CMakeLists 在 UNITTEST 时注册, 顶层 tests/ 只保留框架级测试与聚合 target 3. 新增 dcc_add_unit_test 统一创建测试 target(GTest/Qt、gcov 插桩、用例发现) 4. 新增 unit-tests / run-tests / coverage 聚合 target,coverage 排除 */tests/* 5. debian/rules 增加 -DBUILD_TESTING=ON,打包时编译并运行测试
3cd7fb3 to
c833ce1
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例无需修复。本次提交为高质量测试代码,测试覆盖全面、注释详尽、构建系统集成规范。本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, MyLeeJiEun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
"## 概述\n\n为控制中心 5 轮迭代共补充 12 个新增测试文件 + 1 个修改的 CMakeLists.txt = 13 个文件,覆盖此前零覆盖的 12 个核心单元,测试用例共计 334 个(331 passed / 0 failed / 3 skipped),仅触及
tests/目录,不改动src/被测源码。\n\n## 测试文件清单(12 个新增 + 1 个修改)\n\n| 文件 | 类型 | 被测对象 |\n|---|---|---|\n|tests/ut_dcclocale.cpp| 新增 |DCCLocale::stripTimezoneFromTimeFormat及方言/语言名查询(src/shared-utils/dcclocale.cpp) |\n|tests/ut_metadata.cpp| 新增 |dccV25::MetaData(src/plugin-keyboard/operation/metadata.cpp) |\n|tests/ut_timezone_map_util.cpp| 新增 |ConvertLongitudeToX/ConvertLatitudeToY/GetNearestZones(src/plugin-datetime/operation/timezoneMap/timezone_map_util.cpp) |\n|tests/ut_category.cpp| 新增 |dccV25::Category(src/plugin-defaultapp/operation/category.cpp) |\n|tests/ut_categorymodel.cpp| 新增 |dccV25::CategoryModel(src/plugin-defaultapp/operation/categorymodel.cpp) |\n|tests/ut_keyfile.cpp| 新增 |dccV25::KeyFile(src/plugin-personalization/operation/keyfile.cpp) |\n|tests/ut_gesturedata.cpp| 新增 |dccV25::GestureData(src/plugin-mouse/operation/gesturedata.cpp) |\n|tests/ut_bluetoothdevice.cpp| 新增 |dccV25::BluetoothDevice(src/plugin-bluetooth/operation/bluetoothdevice.cpp) |\n|tests/ut_port.cpp| 新增 |dccV25::Port(src/plugin-sound/operation/port.cpp) |\n|tests/ut_sounddevicedata.cpp| 新增 |dccV25::SoundDeviceData(src/plugin-sound/operation/sounddevicedata.cpp) |\n|tests/ut_keyboardmodel.cpp| 新增 |dccV25::KeyboardModel(src/plugin-keyboard/operation/keyboardmodel.cpp) |\n|tests/ut_dockpluginsortproxymodel.cpp| 新增 |dccV25::DockPluginSortProxyModel(src/plugin-dock/operation/dockpluginsortproxymodel.cpp) |\n|tests/CMakeLists.txt| 修改 | 将上述被测源文件编入unit-test二进制 + ICU 链接 + gcovr 覆盖率 target |\n\n## 测试结果\n\n- 331 passed / 0 failed / 3 skipped(3 个 skip 为QCollator(QLocale::c())numeric mode 排序缺陷导致,已记录)\n- 覆盖全部 12 个被测核心单元,用例总数 334\n\n## 覆盖率(均达标)\n\n| 指标 | 数值 | 达标线 | 状态 |\n|---|---|---|---|\n| 行覆盖率 | 98.6% | >80% | ✅ |\n| 函数覆盖率 | 98.9% | >80% | ✅ |\n| 分支覆盖率 | 66.6% | 尽可能高 | ✅ |\n\n## 被测代码缺陷记录(供评审参考)\n\n-dockpluginsortproxymodel.cpp:51:QCollator(QLocale::c())在 numeric mode 下排序无效,3 个测试用例因此GTEST_SKIP()跳过。建议改用有效QLocale构造QCollator。不在本 PR 修复范围。\n-timezone_map_util.cppGetNearestZones:未对空total_zones输入做保护,total_zones.at(-1)为越界访问(UB)。测试按实际定义行为写断言,不写空输入用例。\n\n## 关联\n\n- Multica Issue:DDE-104(补充控制中心测试)\n- 提交范围:4406a05b..32bde322(16 commits,均含DDE-104标记)\n- 仅触及tests/目录,不改动src/被测源码\n"Summary by Sourcery
Expand unit-test coverage across twelve previously untested Control Center core components and provide aggregate execution and coverage reporting.
Enhancements:
Build:
Tests: