Repository navigation
test(dashboard): port-change 集成测试在围栏没生效时拒跑,不再覆盖真实 bots.json - #2996
Merged
Merged
Conversation
test/dashboard-daemon-port-change.integration.test.ts 在模块顶层用 homedir() 推导 botmuxDir,随后往里写 bots.json、.dashboard-token、.dashboard-secret、.data-dir 和 dashboard 的 daemon 注册表。绕过 setupFiles 的运行(0 字节 vitest 配置)里,这些写入 会直接覆盖真实的 ~/.botmux——bots.json 是全部 bot 的配置。 - 以 require-fenced-data-dir 作为第一个 import:围栏没执行时整文件拒跑; - botmuxDir 算出后立即确认它在本文件的测试围栏里,否则加载阶段就抛错,一个文件都不写。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 08:25
This was referenced Nov 7, 2026
Owner
Author
|
已同步最新 master 到本分支(新 head 270c33d,merge commit,未 force-push、原提交保留)。同步为零冲突纯合并:本 PR 唯一改动文件 test/dashboard-daemon-port-change.integration.test.ts 的 blob 与原 head 13b78e0 逐字节相同;合并树与 git merge-tree 预测一致。集成树本地 build 与相关测试(vitest 双引擎 + bun)全绿,新 head CI 首跑进行中。另:此前阻塞本 PR CI 的 #2981 flake 已由 #3026 修复并合入 master。 |
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
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.
背景
#2976 合并时,复审发现了这一处:
test/dashboard-daemon-port-change.integration.test.ts和那两个文件同一类,而且风险更高。它在模块顶层用
homedir()推导botmuxDir,随后往里写这些文件:bots.json:全部 bot 的配置;.dashboard-token、.dashboard-secret、.data-dir;data/dashboard-daemons/下的 daemon 注册表。平时这些路径由 unit-setup / bun-test-fence 围到临时 HOME。但只要有一次运行绕过 setupFiles(例如 2026-11-06 那次 0 字节 vitest 配置的全量运行),这些写入就会直接覆盖真实的
~/.botmux。改了什么(只改测试)
./helpers/require-fenced-data-dir.js作为第一个 import:围栏没执行时,整个文件在加载阶段就拒跑。botmuxDir一算出来就确认它在本文件的测试围栏(__TEST_DATA_DIR_FENCE)里,不在就在加载阶段抛错。文件里所有写入都从这个目录推导,所以一个文件都不会写。影响面
只改这一个测试文件,生产代码不变。围栏正常时行为不变。
验证
npx vitest run --project unit test/dashboard-daemon-port-change.integration.test.ts:1/1 通过。bun test --timeout=180000 ./test/dashboard-daemon-port-change.integration.test.ts:1/1 通过。事故场景对比:在私有
/tmp的隔离运行器里套临时 HOME,用 0 字节 vitest 配置运行本文件。临时 HOME 里预先放好哨兵bots.json和.dashboard-secret:bots.json.dashboard-secret[{"larkAppId":"cli_port_change"…port-change-test-secret.data-dir、.dashboard-token、daemon 注册表🤖 Generated with Claude Code