From a25ba4b7941534c6f7411253281e3cfee523e4ae Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Tue, 6 Oct 2026 22:44:27 +0800 Subject: [PATCH] =?UTF-8?q?test(gui):=20=E4=BF=AE=20silent-start=20?= =?UTF-8?q?=E5=88=A4=E6=8D=AE=E7=9A=84=E5=AD=97=E8=8A=82=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=81=87=E7=BA=A2=EF=BC=88=E8=A2=AB=E6=B3=A8=E9=87=8A=E6=8C=A4?= =?UTF-8?q?=E7=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题 `make test` / CI 的 `npm test` 都红: ✗ 非静默时经 ready-to-show 显示 — 没有 ready-to-show → show()… ## 归因(逐提交二分) origin/main (7e4f1058) 通过 2bbbb6b8 / bca791a1 通过 3988c198 / 85d76ad4 通过 878fd770 通过 7bd569ec ★ 失败 ← 引入点 04c5883f / 5f12ea3d ★ 失败 不是本次内核改动引入;是 7bd569ec(10-05「修长时间挂后台后打开白屏」) 把 `once` 改成 `on` 时**同时补了一段解释性注释**,把 `ready-to-show` 与 `show()` 的间距从 331 字符推到 558 字符, 而判据的窗口是硬编码 `{0,120}`。 **实现是对的,判据的字节窗口太小。** ## 修法 判据该断的是**结构关系**(ready-to-show 处理器的回调里有 show()), 不是两者相隔多少字符 —— 后者会随注释/排版无意义地红。 - 先去行注释再量(注释不该参与结构判定) - 窗口放到 400(容纳该回调体,仍远小于「跑到别的函数里」的距离) ## 验证 - 修后 `node silent-start.test.mjs` 全部通过 - ★ 变异自证仍能红:删掉 ready-to-show 处理器 → 判据报红 (证明不是把判据改松到什么都不抓) - `make test` 全绿(go test + test-gui + csrc-test + check-csrc + check-codec-cgo-only) Co-Authored-By: Claude Opus 4.8 (1M context) --- cmd/gui/silent-start.test.mjs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/gui/silent-start.test.mjs b/cmd/gui/silent-start.test.mjs index c62f8cb9..66f81220 100644 --- a/cmd/gui/silent-start.test.mjs +++ b/cmd/gui/silent-start.test.mjs @@ -67,7 +67,19 @@ check( ); check( "非静默时经 ready-to-show 显示", - /ready-to-show[\s\S]{0,120}show\(\)/.test(createBlock), + // ★ 2026-10-06:原来写死 `{0,120}` 字符窗口,被新增的**注释**挤爆而假红。 + // + // 实情:main.js 在 ready-to-show 与 show() 之间夹了 558 字符 —— 其中 + // 大部分是解释「为什么用 on 而非 once」的注释(7bd569ec 白屏修复)。 + // 实现是对的,判据的字节窗口太小。 + // + // ⇒ 判据该断的是**结构关系**(ready-to-show 处理器的回调里有 show()), + // 不是两者相隔多少字符 —— 后者会随注释/排版无意义地红。 + // 去掉行注释后再量,且把窗口放到足够容纳该回调体。 + (() => { + const noLineComments = createBlock.replace(/\/\/[^\n]*/g, ""); + return /ready-to-show[\s\S]{0,400}show\(\)/.test(noLineComments); + })(), "没有 ready-to-show → show(),非静默启动可能白屏闪现", ); check(