Skip to content

test(cli-adapters): 写 ~/.botmux 的适配器测试在围栏没生效时拒跑 - #2977

Merged
deepcoldy merged 1 commit into
masterfrom
test/cli-adapters-home-fence
Nov 7, 2026
Merged

deepcoldy merged 1 commit into
masterfrom
test/cli-adapters-home-fence

Conversation

@deepcoldy

Copy link
Copy Markdown
Owner

背景

2026-11-06 16:13–16:17,一次 vitest 全量运行绕过了仓库的全部测试围栏:配置文件是 0 字节,没有 setupFiles,HOME 也没有被重定向。

test/cli-adapters.test.ts 里有两类用例会写由 homedir() 推导的目录:

  • materializePiTurnBoundaryExtension() 写 PI_PLUGIN_DIR/extensions/pi-turn-boundary-extension.js。PI_PLUGIN_DIR 在模块加载时就算好了,即 ~/.botmux/pi-skills。
  • dsh question bridge 的用例写 ~/.botmux/dsh-question-bridge/<hash>/,内容里引用了跑测试那个 worktree 的源码路径。

那次运行把这两处都写进了真实的 ~/.botmux 下。

改了什么(只改测试)

影响面

只改这一个测试文件,生产代码不变。围栏正常时行为不变。

验证

  • npx vitest run --project unit test/cli-adapters.test.ts:498 passed、3 failed、2 skipped。失败的 3 条和未改动的 master 完全一致,都是本机已知的 dsh question bridge 宿主环境问题,与本改动无关。

  • bun test --timeout=180000 ./test/cli-adapters.test.ts:同样 498 pass、3 fail,与 master 一致。

  • 事故场景对比:用 0 字节 vitest 配置、在临时 HOME 下运行本文件,跑完看临时 HOME:

    结果 pi-skills/extensions/…js dsh-question-bridge/
    master 原版 照常执行 写入了 写入了
    本 PR 加载即拒跑 未写入 未写入

🤖 Generated with Claude Code

test/cli-adapters.test.ts 有用例会写 homedir() 推导的目录:
materializePiTurnBoundaryExtension() 写 PI_PLUGIN_DIR/extensions,dsh question
bridge 用例写 ~/.botmux/dsh-question-bridge。2026-11-06 一次绕过 setupFiles 的
vitest 全量运行(0 字节配置)里,这两处写入落在了真实的 ~/.botmux 下。

- 以 require-fenced-data-dir 作为第一个 import:围栏没执行时整文件拒跑;
- pi 扩展用例写入前确认 PI_PLUGIN_DIR 在本文件的测试围栏里。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@deepcoldy
deepcoldy merged commit 36a28f8 into master Nov 7, 2026
15 checks passed
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

🚀 Released in v3.58.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant