fix: resolve 7 production code defects found during test supplementation (DDE-135) - #158
fix: resolve 7 production code defects found during test supplementation (DDE-135)#158MyLeeJiEun wants to merge 2 commits into
Conversation
1. Add tests/ with 6 Qt6::Test ctest targets: thememanager sunrise, wpssl utils/format/dbus, xsettings keyfile/xsutils 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. 109/109 cases pass; coverage (target -fno-exceptions): line 94.9%, function 90.7%, branch 91.0%, all above the 70% bar Influence: 1. Build with -DBUILD_TESTING=ON and run ctest for the 6 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/ 与 6 个 Qt6::Test ctest target:thememanager sunrise、wpssl utils/format/dbus、xsettings keyfile/xsutils 2. 新增 fakeservice.h D-Bus 桩,dbus target 接入 AUTOMOC 3. wallpaperslideshow-utils 用 ctest XDG_CONFIG_HOME 隔离,缺 session bus 时 QSKIP 4. 109/109 用例通过;覆盖率(target -fno-exceptions):行 94.9%、函数 90.7%、分支 91.0%,三项均达 70% 门线 Influence: 1. 以 -DBUILD_TESTING=ON 构建,对 6 个 target 运行 ctest 2. 覆盖率:-fprofile-arcs -ftest-coverage + --coverage 链接, lcov 分支覆盖;测试 target 以 -fno-exceptions 构建
…ion (DDE-135) Production code fixes: linuxdeepin#6 keyfile.cpp: guard against empty QString::front() UB on blank lines linuxdeepin#2 keyfile.cpp: deleteKey now returns true on successful removal linuxdeepin#3 keyfile.cpp: getBool returns defaultValue for missing section (was false) linuxdeepin#4 format.cpp: typeMap maps image/gif -> "gif" (was "jpeg") linuxdeepin#1 utils.cpp: isFileExists checks decoded path (was raw filename) linuxdeepin#7 utils.cpp: WriteStringToFile uses sibling swap file instead of sub-dir linuxdeepin#5 sunrisesunset.cpp: polar-day sunrise normalised to requested date (was -100h) Test updates (flip buggy-behavior assertions to correct behavior): linuxdeepin#3 getBoolMissingSectionReturnsFalseNotDefault -> ReturnsDefault (assert true) linuxdeepin#4 gifMapsToJpegByActualBehavior -> gifMapsToGif (assert "gif") linuxdeepin#1 isFileExistsUriInputReturnsFalseDueToDecodeBug -> ResolvesAfterDecode (assert exists) linuxdeepin#7 writeStringToFileNonEmptyAlwaysFailsDueToSwapDirBug -> WritesContentViaSwap (assert success+content) linuxdeepin#7 writeStringToFileUnwritableParentReturnsFalse -> OverwritesExistingFile (assert overwrite success) linuxdeepin#2 deleteKeyRemovesEntry: added QVERIFY(deleteKey(...)) return-value assertion New test cases: linuxdeepin#6 loadFileSkipsBlankAndWhitespaceLines (empty/whitespace/trailing-no-newline) linuxdeepin#5 polarDayStillReturnsTrue: added sunrise.date()==date assertion All 79 tests pass (26 keyfile + 8 format + 14 sunrisesunset + 31 wpssl-utils).
|
[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 |
|
CLA Assistant Lite bot: shuttle slave seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
|
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 GuideFixes seven production defects in wallpaperslideshow utils/format, xsettings KeyFile, and thememanager SunriseSunset, and wires up a new test suite (Qt6::Test + ctest) that both flips existing assertions from "assert current buggy behavior" to "assert correct behavior" and adds branch-coverage tests for the fixed code paths and XSettings utilities, plus a D-Bus contract test for the WallpaperSlideshow interface. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
概述
在补充 dde-services 单元测试(DDE-106 / 上游测试 PR #151)过程中,发现并确认了 7 处生产代码(被测源码)缺陷。本 PR 按架构师方案逐条修复,并同步更新了相关测试用例(将「按实际错误行为断言」翻转为「按正确行为断言」,并新增覆盖路径)。
test: 补充 dde-services 单元测试与 D-Bus 测试)与 PR #151 的依赖关系(重要)
本分支
fix/dde-135-defects基于 PR #151 的测试提交,包含 2 个 commit:1df7e0a—test: add dde-services unit and D-Bus tests(即 PR test: 补充 dde-services 单元测试与 D-Bus 测试 #151 的内容,本 PR 不修改 test: 补充 dde-services 单元测试与 D-Bus 测试 #151 的该提交)b88305e—fix: resolve 7 production code defects found during test supplementation (DDE-135)(本 PR 新增的缺陷修复 + 测试更新)即本 PR 的修复提交
b88305e直接层叠在 PR #151 的测试提交1df7e0a之上。第 2 个 commit 既修复生产代码,又对 #151 新增的部分测试用例做了断言翻转与增强,因此二者存在依赖。1df7e0a),保留修复提交b88305e。7 处缺陷修复
生产代码修复(4 文件)
loadFile空行QString::front()UBsrc/plugin-qt/xsettings/modules/api/keyfile.cppreplace("^ +")后、front()前新增if (line.isEmpty()) continue;deleteKey恒返回 falsereturn false;→return true;(section 缺失仍 false)getBoolsection 缺失返回值不一致return false;→return defaultValue;,与getStr一致typeMapgif 映射错误src/plugin-qt/wallpaperslideshow/background/format.cpp{"image/gif","jpeg"}→{"image/gif","gif"}isFileExistsURI 解码结果未用src/plugin-qt/wallpaperslideshow/utils.cppQFile::exists(filename)→QFile::exists(path)WriteStringToFile.swap目录 bugswapFile = filename + ".swap"(同级文件,非子路径);mkpath确保父目录存在;写 swap 文件后remove旧文件再rename(QtQFile::rename拒绝覆盖已存在目标)sunrise值无意义src/plugin-qt/thememanager/sunrisesunset.cppsunsetUT哨兵修复后对称新增if (sunriseUT <= -100) sunriseUT = 0;,极昼 sunrise 归一到请求日 0 点测试代码更新(4 文件,+101/-54)
getBoolMissingSectionReturnsFalseNotDefault→getBoolMissingSectionReturnsDefaultfalse→true,补defaultValue=false对称断言gifMapsToJpegByActualBehavior→gifMapsToGif"jpeg"→"gif"isFileExistsUriInputReturnsFalseDueToDecodeBug→isFileExistsUriInputResolvesAfterDecode!exists→exists,补不存在 URI 仍 falsewriteStringToFileNonEmptyAlwaysFailsDueToSwapDirBug→writeStringToFileWritesContentViaSwap.swap残留writeStringToFileUnwritableParentReturnsFalse→writeStringToFileOverwritesExistingFiledeleteKeyRemovesEntryQVERIFY(kf.deleteKey(...))锁定返回 trueloadFileSkipsBlankAndWhitespaceLinespolarDayStillReturnsTrue增强QCOMPARE(sunrise.date(), date)断言验证情况
QSaveFile消除remove+rename间的原子性窗口;当前该函数无生产调用方,风险纯理论)。[deepin-service-plugins] Updates for project Deepin Desktop Environment #4isBackgroundFile行为不变、chore: 添加libglib2.0-dev构建依赖 #5 白昼判定逻辑不变的无回归结论成立。dpkg-buildpackage成功,产出dde-services_1.0.25_amd64.deb。Summary by Sourcery
Fix seven production defects and add regression coverage for the affected services and interfaces.
Bug Fixes:
Enhancements:
Build:
Tests: