Repository navigation
test(debug): 避免超时测试依赖适配器先连接 watch(#1962) - #2341
Merged
1lck merged 5 commits intoNov 24, 2026
Merged
Conversation
…962-announced-adapter-cleanup-test
1 task done
1lck
marked this pull request as ready for review
November 24, 2026 02:23
1lck
deleted the
lithe-support/issue-1962-announced-adapter-cleanup-test
branch
November 24, 2026 02:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
#1962 报告
desktop/internal/workbench/debug_announced_test.go的TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut偶发失败:测试曾依赖固定初始化超时窗口(最初 300ms、后放宽至 3s)与外部子进程启动并连接观察 socket(watch)竞争;超时先触发并结束子进程后,测试继续等待watch.ended,等满 20s 误报the adapter process never connected to the watch。此外,依靠 3s 实时定时器还会让单测耗时超过 3s,触发稳定性计时警告,且若h.clickNamed内的settle()循环跨过超时窗口,之后再读p.debug.activeSession()会得到nil。改动 / Changes
desktop/internal/workbench/app.go、desktop/internal/workbench/debug_start.go:为App增加测试专用的确定性触发通道debugInitializeTrigger <-chan struct{}(生产代码为nil,不改变生产watchDebugInitialize定时器行为与超时语义);非nil时watchDebugInitialize等待<-trigger或<-session.ctx.Done(),无超时泄漏。desktop/internal/workbench/debug_announced_test.go:announcedWatch增加awaitConnected(t, limit)并由t.Cleanup一并关闭未移交的w.conn;TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut使用debugInitializeTrigger:点击 Start 拿到会话后,先通过watch.awaitConnected(t, 20*time.Second)确认测试子进程已真实启动并建立观察连接,再close(trigger)确定性触发超时;随后校验p.debug.failure == h.app.text.Debug.TimedOut、p.debug.activeSession() == nil,并通过watch.ended、awaitDebugSessionDone与<-session.cleanupDone确认进程退出和会话清理全部有界完成(单测耗时从 3080ms 降至 60ms)。shared/platform-feature-matrix/features/debug-tcp-transport.json:更新verification和notes以反映确定性超时触发及退出/清理验证;保持 macOS/WindowsverificationStatus: pending。origin/main(913661835)以对齐最新仓库状态。不在本 PR 范围内 / Out of scope
TestDebugTCPAdapterThatNeverInitializesTimesOut与TestDebugHostedAdapterThatNeverAnswersIsRecordedAsATimeout)仍使用debugInitializeWindow = 300ms,按develop-lithe第九节已单独提交重构单 [Feature] 统一 hosted 调试初始化超时测试到确定性触发通道并清理 debugInitializeWindow #2368,不在本 PR 夹带修改。类型专属:fix
复现与根因
-race下运行TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut时,固定debugInitializeWindow(300ms / 3s)可能早于子进程拨号watch触发,导致进程被正常终止但watch.ended误报超时。期望测试与子进程启动确定性同步后触发初始化超时,并完整验证进程退出与清理。49827fd4c)将其放大为3 * time.Second仍保留时间竞争。desktop/internal/workbench测试与watchDebugInitialize逻辑。检查项
test-stability-macos.sh触发SLOW 3080ms(且固定窗口存在与子进程连接watch竞争);改用debugInitializeTrigger后降至 60ms,并通过-race -count=20与-tags 'dev vivahead' -count=10全部通过test-stability-macos.sh与-race -count=20压测验证watchDebugInitialize、debugInitializeWindow、awaitDebugSessionDone的全部调用方(desktop/internal/workbench/)desktop/internal/workbench/debug_start.go和debug_announced_test.godebugInitializeWindow = 300ms已单独提交refactorIssue:[Feature] 统一 hosted 调试初始化超时测试到确定性触发通道并清理 debugInitializeWindow #23682026-10-27-debug-tcp-transport-lifecycle.md仍适用范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/debug-tcp-transport.json:verification与notes已如实说明#1962确定性超时验证;verificationStatus保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(222 项能力通过).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空debug_announced_test.go仅使用内联合成插件清单dev.lithe.test.debug-announced与复制的测试二进制自身,不读取任何具体插件debug-tcp-transport.json仅记录宿主tcpAnnounced传输能力shared/i18n/,未将插件构建说明写入宿主文档UI 验证 / UI evidence
N/A:没有生产 UI、布局、文案或交互状态变化(仅新增
App.debugInitializeTrigger测试触发通道并修复稳定性测试)。统一日志系统 / Structured logging
N/A:没有新增或修改生产日志事件或失败处理边界。
界面文案 / i18n
N/A:没有新增或修改用户可见文案;i18n 检查通过。
逻辑归属 / Logic placement
debugInitializeTrigger是 Go 测试向watchDebugInitialize注入确定性触发信号的测试辅助字段,不改变任何业务规则或 Core 职责边界(超时时长与策略仍由 CoreDebugTransportPolicy决定)性能与内存 / Performance and memory
N/A:生产路径未新增后台任务、轮询、定时器或内存分配(
debugInitializeTrigger在生产中为nil);测试通道由session.ctx.Done()与t.Cleanup有界收尾。设置 / Settings
N/A:没有设置项变化。
插件契约 / Plugin contract
N/A:没有插件契约、宿主方法、能力版本或 SDK 变化。
发行包与资源 / Bundle and resources
N/A:没有运行时资源或发行包变化;
verify-runtime-bundle-immutability.sh通过。无用代码与重构 / Dead code and refactoring
debugInitializeWindow = 300ms未在本 PR 顺手改动,已提交refactorIssue:[Feature] 统一 hosted 调试初始化超时测试到确定性触发通道并清理 debugInitializeWindow #2368验证 / Verification
环境:macOS arm64,Go 1.27.4,固定 Core
076ce04e314ecdde790b36ee3f374becb11951a0(合并origin/main913661835后,HEAD4629cd383)。gofmt -l desktop/&git diff --check origin/main...HEAD./scripts/desktop/desktop-go.sh vet ./...&vet -tags dev ./..../.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/workbench -- --filter '^TestDebugAnnounced'TestDebugAnnouncedAdapterRunnerskip;TestDebugAnnouncedAdapterThatNeverAnnouncesTimesOut60ms,其余 70ms/70ms/1370ms;报告.artifacts/test-stability/index.html)./scripts/desktop/desktop-go.sh test -race -count=20 ./internal/workbench -run '^TestDebugAnnounced'ok ... 117.451s)./scripts/desktop/desktop-go.sh test -tags 'dev vivahead' -count=10 ./internal/workbench -run '^TestDebugAnnounced'ok ... 9.177s)./scripts/desktop/desktop-go.sh test -count=1 ./internal/workbench -run '^TestDebug'ok ... 12.641s)./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/main-race -count=20+ 人工审查确认)./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD&verify-platform-feature-matrix.sh./scripts/agent-notes/verify-agent-notes.shnode scripts/i18n/verify-app-language-localization.mjs&node scripts/i18n/generate-i18n.mjs --check./scripts/desktop/verify/verify-runtime-bundle-immutability.shrg&node scripts/desktop/validate-pins.mjsrg0 命中;pins 有效可达)未能执行的检查和原因: Windows 本地虚拟机未执行(Windows 当前未接入
tcpAnnounced宿主,由 Windows CI 覆盖编译与测试);macOS 原生桌面界面全链路验收保持矩阵pending。提交前确认 / Final checks
origin/main(913661835),目标分支为main.build/、target/、dist/、.artifacts/、PNG 或extension-host/