From 3ca6710f3d90ed2efd5888ff98c3fe71842ba477 Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 22 Aug 2026 13:51:00 +0800 Subject: [PATCH] =?UTF-8?q?test:=20idle=20snapshot=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=94=B9=E8=BD=AE=E8=AF=A2=E7=AD=89=E5=BE=85,=E6=B6=88?= =?UTF-8?q?=E9=99=A4=E6=BB=A1=E8=BD=BD=20runner=20=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=BA=8F=E6=8A=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 固定 100ms 睡眠在满载 CI runner 上会被 20ms 空闲计时器超出 主线程调度窗口,今天三次假失败(#287/#306/#311)。改为最长 2s 的 10ms 轮询:正常路径仍在一个空闲延迟内返回,只有真实失败才 等满时限;断言语义(恰好一条、最小修订 2)不变。 --- Tests/WeiBeiSafetyTests/NoteEditingSessionTests.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Tests/WeiBeiSafetyTests/NoteEditingSessionTests.swift b/Tests/WeiBeiSafetyTests/NoteEditingSessionTests.swift index 7ddaebb1a..2d9a9977e 100644 --- a/Tests/WeiBeiSafetyTests/NoteEditingSessionTests.swift +++ b/Tests/WeiBeiSafetyTests/NoteEditingSessionTests.swift @@ -175,7 +175,15 @@ final class NoteEditingSessionTests: XCTestCase { session.receive(dirtyEvent(for: session, revision: 1)) session.receive(dirtyEvent(for: session, revision: 2)) - try await Task.sleep(for: .milliseconds(100)) + // Poll instead of one fixed sleep: on a loaded CI runner the 20ms idle + // timer can outrun the main thread well past any fixed window, which + // made this test flap (commands still empty at assertion time). The + // happy path still returns in one idle delay; only a real failure now + // waits out the deadline. + let deadline = Date().addingTimeInterval(2) + while commands.isEmpty && Date() < deadline { + try await Task.sleep(for: .milliseconds(10)) + } XCTAssertEqual(commands.count, 1) XCTAssertEqual(commands.first?.minimumRevision, 2)