test: 补充 dde-services 单元测试与 D-Bus 测试 - #151
Conversation
There was a problem hiding this comment.
Sorry @MyLeeJiEun, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
|
Hi @MyLeeJiEun. Thanks for your PR. 😃 |
|
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. |
|
TAG Bot New tag: 1.0.40 |
|
TAG Bot New tag: 1.0.41 |
78f2f95 to
c8aa2c9
Compare
c8aa2c9 to
1df7e0a
Compare
1. Add tests/ with 7 Qt6::Test ctest targets: thememanager sunrise, wpssl utils/format/dbus, xsettings keyfile/xsutils/xsdatainfo, gated by BUILD_TESTING 2. Add fakeservice.h D-Bus stub; enable AUTOMOC on the dbus target 3. Isolate wpssl-utils via ctest XDG_CONFIG_HOME; QSKIP on no bus 4. Restore include(CTest) in root CMakeLists so BUILD_TESTING defaults on and enable_testing() runs (lost in prior squash) 5. 134/134 cases pass; coverage (target -fno-exceptions): line 96.9%, function 94.2%, branch 93.5%, all above the 70% bar Influence: 1. Build with -DBUILD_TESTING=ON and run ctest for the 7 targets 2. Coverage via -fprofile-arcs -ftest-coverage + --coverage link, lcov branch coverage; build the test target with -fno-exceptions test: 补充 dde-services 单元测试与 D-Bus 测试 1. 新增 tests/ 与 7 个 Qt6::Test ctest target:thememanager sunrise、wpssl utils/format/dbus、xsettings keyfile/xsutils/xsdatainfo,由 BUILD_TESTING 门控 2. 新增 fakeservice.h D-Bus 桩,dbus target 接入 AUTOMOC 3. wallpaperslideshow-utils 用 ctest XDG_CONFIG_HOME 隔离,缺 session bus 时 QSKIP 4. 恢复根 CMakeLists 的 include(CTest),使 BUILD_TESTING 默认开启 且 enable_testing() 生效(此前 squash 丢失该行) 5. 134/134 用例通过;覆盖率(target -fno-exceptions):行 96.9%、函数 94.2%、分支 93.5%,三项均达 70% 门线 Influence: 1. 以 -DBUILD_TESTING=ON 构建,对 7 个 target 运行 ctest 2. 覆盖率:-fprofile-arcs -ftest-coverage + --coverage 链接, lcov 分支覆盖;测试 target 以 -fno-exceptions 构建
1df7e0a to
cf2d7d3
Compare
测试补充:dde-services 单元测试 + D-Bus 契约测试
为 dde-services 新增项目根
tests/目录与 7 个 ctest target(框架 Qt6::Test,门控BUILD_TESTING),覆盖此前无测试的 thememanager / wallpaperslideshow / xsettings 核心逻辑,以及 wallpaperslideshow 的 D-Bus 接口契约。新增文件
tests/CMakeLists.txtset(CMAKE_AUTOMOC ON);wallpaperslideshow-utils经 ctestXDG_CONFIG_HOME隔离写操作;dbus target 源列表接入fakeservice.h触发 AUTOMOCtests/tst_sunrisesunset.cppSunriseSunset纯算法单元测试tests/tst_wpssl_utils.cpputils静态助手单元测试tests/tst_format.cppFormatPictureMIME→类型映射单元测试tests/tst_keyfile.cppKeyFileini/.desktop 解析 + 序列化往返单元测试tests/tst_xsutils.cppUtilsXSETTINGS 字节助手单元测试tests/tst_xsdatainfo.cppXSItemInfo/XSDataInfo纯字节 marshal/unmarshal 单元测试(+23 用例)tests/fakeservice.horg.deepin.dde.WallpaperSlideshow最小实现tests/tst_wallpaperslideshow_dbus.cppCMakeLists.txtinclude(CTest)(project(dde-services)之后);末尾追加BUILD_TESTING门控接入tests/测试结果
tst-xsdatainfo覆盖xsettings/impl/xsdatainfo.cpp纯字节 marshal/unmarshal)覆盖率(测试 target 以
-fno-exceptions构建,gcov + lcov 分支覆盖)三项均达标。注:默认 flags 下分支覆盖偏低,差距来自 gcc 对 Qt6
noexcept代码生成的反向异常清理分支(不可达);测试 target 加-fno-exceptions后实际逻辑分支覆盖 93.5%。新增xsettings/impl/xsdatainfo.cpp100% 分支覆盖(52/52)为主要贡献。构建要点(已修复)
include(CTest):第二轮 squash 到 fork master 基线时丢失了根CMakeLists.txt的include(CTest),导致默认配置下BUILD_TESTING未定义、enable_testing()未调用 → 测试 target 不构建、ctest 找不到测试。本轮已恢复(project(dde-services)之后),以本地e70c5ee为准,与 upstream master 一致。PR 现开箱即用:默认配置即启用测试。add_executable(tst-wallpaperslideshow-dbus ...)源列表加入${CMAKE_CURRENT_SOURCE_DIR}/fakeservice.h,使 AUTOMOC 生成FakeWallpaperSlideshowService的 MOC,消除 vtable 链接错误。tst-xsdatainfo的 AUTOMOC 由源列表中xsdatainfo.cpp触发(其#include "xsdatainfo.h"),无需额外处理。wallpaperslideshow-utils用例经 ctestset_tests_properties(... ENVIRONMENT "XDG_CONFIG_HOME=...")重定向writeWallpaperConfig写路径,未设时QSKIP,不污染真实用户配置。org.deepin.dde.WallpaperSlideshow.Test.p<pid>在隔离 session bus 上运行,session bus 不可用时QSKIP。记录的被测代码缺陷(仅记录,未修改被测代码)
wallpaperslideshow/utils.cppisFileExists:URI 解码结果未使用,对原始filename判存在,URI 输入恒判不存在。xsettings/keyfile.cppKeyFile::deleteKey:键已移除但恒返回 false。xsettings/keyfile.cppKeyFile::getBool:section 缺失时恒返回 false(非 defaultValue)。wallpaperslideshow/background/format.cppFormatPicture::typeMap:image/gif映射为"jpeg"(疑误)。thememanager/sunrisesunset.cppSunriseSunset:极昼/极夜位置sunrise值无意义。wallpaperslideshow/utils.cppWriteStringToFile:swapFile=filename+"/.swap"经QDir.mkpath建成目录,QFile::open(WriteOnly)打开目录失败(EISDIR),非空名恒返回 false。对缺陷 #1/#2/#5/#6,测试按实际行为断言并注释标注,未掩盖。
验证指令
Related Multica issue: DDE-106 (id
6f46b926-e537-4e11-a557-252426580cc9)