test(dconfig): add unit tests for dconfig-center - #161
Conversation
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
|
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 substantially expands dconfig-center unit coverage by adding global/helper tests and many connection, resource, and server edge-case tests, while improving fixture isolation with RAII guards and temporary paths. It also makes tests discoverable through CTest and adds optional lcov reporting controlled by CMake options; the reported result is 202 passed, 0 failed, 6 skipped, with 86.3% line and 96.9% function coverage. 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="dconfig-center/tests/CMakeLists.txt" line_range="14" />
<code_context>
set(AUTOMOC_COMPILER_PREDEFINES ON)
-set(DTK_HAS_UNIT_TEST ON)
+option(ENABLE_COVERAGE "Enable coverage instrumentation" ON)
# for coverage
-if (DTK_HAS_UNIT_TEST)
</code_context>
<issue_to_address>
**issue:** ENABLE_COVERAGE defaults to ON, so configuring with the default options instruments and links the test binary for coverage instead of leaving coverage disabled by default as the change description specifies.
**Triggers:** When the project is configured without explicitly setting ENABLE_COVERAGE.
**Suggested fix:** Change the option default to OFF.
```suggestion
option(ENABLE_COVERAGE "Enable coverage instrumentation" OFF)
```
</issue_to_address>
### Comment 2
<location path="dconfig-center/tests/test_helper.hpp" line_range="17" />
<code_context>
+ if (m_name)
+ restore();
+ if (!m_createdDir.isEmpty())
+ QDir().rmpath(m_createdDir);
+ }
void set(const char *name, const QByteArray &value)
</code_context>
<issue_to_address>
**issue (bug_risk):** EnvGuard calls QDir::rmpath() rather than recursively removing the directory contents, so files created below an environment-provided directory prevent cleanup and leave test artifacts behind.
**Triggers:** When a guarded environment path is newly created and a test writes files or subdirectories beneath it.
**Suggested fix:** Use `QDir(m_createdDir).removeRecursively()` for the directory created by the guard.
```suggestion
QDir(m_createdDir).removeRecursively();
```
</issue_to_address>| set(AUTOMOC_COMPILER_PREDEFINES ON) | ||
|
|
||
| set(DTK_HAS_UNIT_TEST ON) | ||
| option(ENABLE_COVERAGE "Enable coverage instrumentation" ON) |
There was a problem hiding this comment.
issue: ENABLE_COVERAGE defaults to ON, so configuring with the default options instruments and links the test binary for coverage instead of leaving coverage disabled by default as the change description specifies.
Triggers: When the project is configured without explicitly setting ENABLE_COVERAGE.
Suggested fix: Change the option default to OFF.
| option(ENABLE_COVERAGE "Enable coverage instrumentation" ON) | |
| option(ENABLE_COVERAGE "Enable coverage instrumentation" OFF) |
| if (m_name) | ||
| restore(); | ||
| if (!m_createdDir.isEmpty()) | ||
| QDir().rmpath(m_createdDir); |
There was a problem hiding this comment.
issue (bug_risk): EnvGuard calls QDir::rmpath() rather than recursively removing the directory contents, so files created below an environment-provided directory prevent cleanup and leave test artifacts behind.
Triggers: When a guarded environment path is newly created and a test writes files or subdirectories beneath it.
Suggested fix: Use QDir(m_createdDir).removeRecursively() for the directory created by the guard.
| QDir().rmpath(m_createdDir); | |
| QDir(m_createdDir).removeRecursively(); |
| #include "dconfig_global.h" | ||
| #include "test_helper.hpp" | ||
|
|
||
| static const QString LocalPrefix = QDir::tempPath() + "/dde-app-services-test-" + |
There was a problem hiding this comment.
QDir::tempPath(),已经不会再重复了吧,是不是不需要Pid这一级去重,
02839bc to
43442f4
Compare
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
43442f4 to
94b9030
Compare
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
94b9030 to
97fd978
Compare
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
97fd978 to
02b6e89
Compare
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
1. Add ut_dconfig_global.cpp for global utility function tests 2. Add ut_helper.cpp for cache manager and helper function tests 3. Expand ut_dconfigconn.cpp with 8 new test cases 4. Expand ut_dconfigserver.cpp with 9 new test cases 5. Fix reload_withFileChange test path resolution in ut_dconfigserver 6. Add MetaFileGuard RAII and improve EnvGuard cleanup in test_helper 7. Update CMakeLists.txt with ENABLE_COVERAGE option and new sources Influence: 1. Verify all 202 test cases pass with 0 failures 2. Check coverage meets line 86.3% and function 96.9% thresholds 3. Validate ENABLE_COVERAGE option defaults to OFF 4. Test reload_withFileChange with correct path resolution test(dconfig): 补充 dconfig-center 单元测试 1. 新增 ut_dconfig_global.cpp 全局工具函数测试 2. 新增 ut_helper.cpp 缓存管理器及辅助函数测试 3. 扩展 ut_dconfigconn.cpp 新增 8 个测试用例 4. 扩展 ut_dconfigserver.cpp 新增 9 个测试用例 5. 修复 ut_dconfigserver 中 reload_withFileChange 测试路径解析问题 6. 新增 MetaFileGuard RAII 并改进 EnvGuard 清理逻辑 7. 更新 CMakeLists.txt 增加 ENABLE_COVERAGE 选项及新测试源文件 Influence: 1. 验证全部 202 个测试用例通过且无失败 2. 检查覆盖率达标(行 86.3%,函数 96.9%) 3. 验证 ENABLE_COVERAGE 选项默认关闭 4. 测试 reload_withFileChange 路径解析正确性
…target 1. Gate the dconfig-center tests behind BUILD_TESTING via include(CTest) 2. Register the dconfigtest executable with ctest 3. Add coverage target that runs tests and generates the lcov report Log: Gate dconfig-center tests with BUILD_TESTING and add a coverage target test(dconfig-center): 以 BUILD_TESTING 门控测试并新增 coverage 目标 1. 通过 include(CTest) 将 dconfig-center 测试纳入 BUILD_TESTING 门控 2. 将 dconfigtest 可执行文件注册到 ctest 3. 新增 coverage 目标,执行测试并生成 lcov 报告 Log: 以 BUILD_TESTING 门控 dconfig-center 测试,并新增 coverage 目标
02b6e89 to
b3b4532
Compare
|
Warning
详情 {
"unset": {
"dconfig-center/tests/test_helper.hpp": {
"b": [
" qunsetenv(m_name);"
]
},
"dconfig-center/tests/ut_dconfigconn.cpp": {
"b": [
" qunsetenv(\"STATE_DIRECTORY\");",
" qunsetenv(\"STATE_DIRECTORY\");",
"// Branch: isDefaultValue() returns true for unset key (default)"
]
},
"dconfig-center/tests/ut_helper.cpp": {
"b": [
" qunsetenv(\"DSG_CONFIG_CONNECTION_DISABLE_DBUS\");"
]
}
}
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Summary
补充 dde-app-services dconfig-center 单元测试代码,提升测试覆盖率。
Multica Issue: DDE-207
Changes
ut_dconfig_global.cpp— 全局工具函数测试(formatDBusObjectPath / getUserNameByUid 等)ut_helper.cpp— 缓存管理器及辅助函数测试(ConfigSyncRequestCache / RefManager 等)ut_dconfigconn.cpp— 新增 8 个测试用例,修复 save 断言路径匹配问题ut_dconfigserver.cpp— 新增 9 个测试用例,修复 reload_withFileChange 路径解析test_helper.hpp— 新增 MetaFileGuard RAII,EnvGuard 改用 rmpath 递归清理CMakeLists.txt— ENABLE_COVERAGE 选项条件控制覆盖率,新增测试源文件Test Results
License
文件头版权声明年份已更新为 2026。
Summary by Sourcery
Increase dconfig-center test coverage and make the test suite independently runnable with integrated CTest and coverage support.
Enhancements:
Build:
Tests:
Chores: