From e20ce78e026bcb32d8bb437232f66476bf398729 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:02:20 +0000 Subject: [PATCH 1/2] fix(test): await provider debug session cleanup before TempDir teardown (#1956) --- desktop/internal/workbench/title_run_test.go | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/desktop/internal/workbench/title_run_test.go b/desktop/internal/workbench/title_run_test.go index 1bd3b3fa9d..dc27acfed2 100644 --- a/desktop/internal/workbench/title_run_test.go +++ b/desktop/internal/workbench/title_run_test.go @@ -153,7 +153,33 @@ func TestProviderDebugStartsTheNamedAdapter(t *testing.T) { p.debug.adapters = []debugAdapter{decoy, named} h.app.startProviderDebug(p, named.PluginID, core.BuildDebugPreparation{Adapter: named.Declaration.ID, Program: "bin/app", WorkingDirectory: "."}, nil) session := p.debug.activeSession() - if session == nil || session.adapter.Declaration.ID != named.Declaration.ID { + if session == nil { + t.Fatal("the provider did not start a debug session") + } + // Stop the session before the harness deletes its preference and plugin + // directories. Waiting for cleanupDone also covers a late startup or an + // assertion failure, when the normal project teardown could race TempDir. + t.Cleanup(func() { + if p.debug.hasSession(session) { + h.app.endDebugSession(p, session) + } + awaitStateWithin(t, h, debugAdapterExitWait, "the provider debug session cleanup", func() bool { + if session.cleanupDone == nil { + return false + } + select { + case <-session.cleanupDone: + return true + default: + return false + } + }) + if session.cleanupErr != nil { + t.Errorf("provider debug cleanup: %v", session.cleanupErr) + } + h.settle() + }) + if session.adapter.Declaration.ID != named.Declaration.ID { t.Fatalf("session = %+v, want adapter %q", session, named.Declaration.ID) } launch := p.debug.pendingRemote.launchTarget From 2fc1cb8113c07e0ddac01db96336dd0fe564e090 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Tue, 17 Nov 2026 12:36:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test(desktop):=20harness=20=E6=94=B6?= =?UTF-8?q?=E5=B0=BE=E6=97=B6=E5=81=9C=E6=AD=A2=E8=B0=83=E8=AF=95=E3=80=81?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=92=8C=E6=B5=8B=E8=AF=95=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=EF=BC=8C=E8=A6=86=E7=9B=96=E6=89=80=E6=9C=89=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=20(#1956)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closeProject 遇到运行中的会话会先弹退出确认,finishCloseProject 没有执行, harness 的兜底路径只取消项目上下文。适配器进程退出后由 untrack 写偏好目录里的 进程台账,这个写入不在 a.tasks 里,和 TempDir 删除竞争。兜底路径按 finishCloseProject 的顺序释放测试、调试、运行、构建和 VCS 会话,h.app.wait() 随后等清理任务结束。去掉单个测试里的重复清理。 --- desktop/internal/workbench/app_test.go | 10 +++++++++ desktop/internal/workbench/title_run_test.go | 23 -------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/desktop/internal/workbench/app_test.go b/desktop/internal/workbench/app_test.go index bf5c96d803..898acefd82 100644 --- a/desktop/internal/workbench/app_test.go +++ b/desktop/internal/workbench/app_test.go @@ -127,6 +127,16 @@ func newHarnessWithDriver(t testing.TB, options Options, open func(app.Config) ( // the serve loops; cancel them before waiting for every task. h.app.stopAllPluginServers() if p := h.app.project; p != nil { + // A running test, debug session or run makes closeProject ask for the + // exit confirmation, so finishCloseProject never stopped them. Release + // them the same way here: their cleanup tasks wait for each process to + // exit and leave the process ledger in the preference directory, and + // h.app.wait() below then waits for those tasks before TempDir removal. + h.app.stopTestsForProject(p) + h.app.stopDebugForProject(p) + h.app.stopRunsForProject(p) + h.app.stopBuild(p) + h.app.stopVcs(p) p.cancel() h.app.closeTree(p) h.app.releaseProjectSearch(p) diff --git a/desktop/internal/workbench/title_run_test.go b/desktop/internal/workbench/title_run_test.go index dc27acfed2..4e8fdb90d1 100644 --- a/desktop/internal/workbench/title_run_test.go +++ b/desktop/internal/workbench/title_run_test.go @@ -156,29 +156,6 @@ func TestProviderDebugStartsTheNamedAdapter(t *testing.T) { if session == nil { t.Fatal("the provider did not start a debug session") } - // Stop the session before the harness deletes its preference and plugin - // directories. Waiting for cleanupDone also covers a late startup or an - // assertion failure, when the normal project teardown could race TempDir. - t.Cleanup(func() { - if p.debug.hasSession(session) { - h.app.endDebugSession(p, session) - } - awaitStateWithin(t, h, debugAdapterExitWait, "the provider debug session cleanup", func() bool { - if session.cleanupDone == nil { - return false - } - select { - case <-session.cleanupDone: - return true - default: - return false - } - }) - if session.cleanupErr != nil { - t.Errorf("provider debug cleanup: %v", session.cleanupErr) - } - h.settle() - }) if session.adapter.Declaration.ID != named.Declaration.ID { t.Fatalf("session = %+v, want adapter %q", session, named.Declaration.ID) }