Repository navigation
test(terminalwidget): 终端单元测试迁移到自研实现 - #598
deepin-bot[bot] merged 1 commit into
Conversation
三方终端替换为自研 DTerminal 组件后,原先依赖 qtermwidget、TerminalDisplay 的 ut_termwidget、ut_termwidgetpage、ut_mainwindow 三个用例文件被排除出构建。 本次将它们改为调用自研接口并重新启用,同时清理测试侧遗留的三方用例开关与 残留头文件。 启用后暴露出两处测试基建缺陷,一并修复:UT_MainWindow_Test 用 deleteLater 释放的窗口会泄漏到后续套件,其集中析构挤占事件循环,使后续用例的定时器错过 等待窗口;UT_Dbusmanager_Test 延迟析构 DBusManager,与 QtDBus 工作线程的 消息投递并发时会导致进程崩溃。前者在 TearDown 主动排空延迟删除队列,后者 改为确定性析构。 全量单元测试 427 项全部通过(启用前 281 项),连续两轮无失败。 Log:终端单元测试由三方接口迁移到自研实现,并修复两处测试基建缺陷。 PMS:TASK-398539
Reviewer's GuideConfigurationRe-enable the terminal-related test sources by removing the exclusion filter from the test source list.
TestsMigrate MainWindow tests from third-party terminal interfaces to DTerminalView and add deterministic cleanup and behavior assertions for deferred windows, paste, zoom, and select-all.
Use deterministic destruction for DBusManager to avoid deferred cleanup racing with DBus message delivery.
Remove the obsolete third-party terminal test switches and their unused export header.
Remove obsolete third-party terminal includes from the TermWidget test.
Update TermWidgetPage tests to observe DTerminal cursor, blinking, scroll, and codec behavior through the self-developed terminal interfaces.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/src/main/ut_mainwindow_test.cpp" line_range="114" />
<code_context>
+ // 若改用 deleteLater(),析构会被推迟到后续用例/套件的事件循环里,
+ // 与 DBus 线程的消息投递并发,曾导致进程 SIGSEGV。
+ delete m_pDbusManager;
}
#ifdef UT_DBUSMANAGER_TEST
</code_context>
<issue_to_address>
**Unrelated objects are deleted early**
When an unrelated object has a pending DeferredDelete event when this fixture tears down, `sendPostedEvents(nullptr, QEvent::DeferredDelete)` drains deferred deletions for every object in the application, not only windows created by this fixture. A pending deletion owned by another fixture or shared service is therefore processed during this teardown, changing its lifetime and potentially invalidating state still used by later tests.
Drain deferred deletes only for windows created by this fixture, or track and clean up those windows explicitly.
</issue_to_address>| // 部分用例以 deleteLater() 释放自建窗口,这里主动排空延迟删除队列, | ||
| // 避免窗口泄漏到后续用例/后续套件(泄漏会拖慢其它用例的定时器与事件处理) | ||
| QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); | ||
| } |
There was a problem hiding this comment.
🟡 Medium · Unrelated objects are deleted early
When an unrelated object has a pending DeferredDelete event when this fixture tears down, sendPostedEvents(nullptr, QEvent::DeferredDelete) drains deferred deletions for every object in the application, not only windows created by this fixture. A pending deletion owned by another fixture or shared service is therefore processed during this teardown, changing its lifetime and potentially invalidating state still used by later tests.
Drain deferred deletes only for windows created by this fixture, or track and clean up those windows explicitly.
Prompt for AI agents
In `tests/src/main/ut_mainwindow_test.cpp` at line 114:
**Unrelated objects are deleted early**
When an unrelated object has a pending DeferredDelete event when this fixture tears down, `sendPostedEvents(nullptr, QEvent::DeferredDelete)` drains deferred deletions for every object in the application, not only windows created by this fixture. A pending deletion owned by another fixture or shared service is therefore processed during this teardown, changing its lifetime and potentially invalidating state still used by later tests.
Drain deferred deletes only for windows created by this fixture, or track and clean up those windows explicitly.|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Kakueeen, lzwind 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) |
318daeb
into
linuxdeepin:develop/terminalwidget
三方终端替换为自研 DTerminal 组件后,原先依赖 qtermwidget、TerminalDisplay 的 ut_termwidget、ut_termwidgetpage、ut_mainwindow 三个用例文件被排除出构建。本次将它们改为调用自研接口并重新启用,同时清理测试侧遗留的三方用例开关与残留头文件。
启用后暴露出两处测试基建缺陷,一并修复:UT_MainWindow_Test 用 deleteLater 释放的窗口会泄漏到后续套件,其集中析构挤占事件循环,使后续用例的定时器错过等待窗口;UT_Dbusmanager_Test 延迟析构 DBusManager,与 QtDBus 工作线程的消息投递并发时会导致进程崩溃。前者在 TearDown 主动排空延迟删除队列,后者改为确定性析构。
验证:全量单元测试 427 项全部通过(启用前 281 项),连续两轮无失败;另外实测将 3rdparty 目录整体移出后,全新 configure + 全量重编 + 全量单测仍全部通过。
Log:终端单元测试由三方接口迁移到自研实现,并修复两处测试基建缺陷。
PMS:TASK-398539
Summary by Sourcery
将终端单元测试迁移至自研 DTerminal 实现,清理第三方测试残留,并提升测试资源清理与 DBus 生命周期管理的稳定性。
Bug Fixes:
Enhancements:
Tests: