Skip to content

Commit a72d439

Browse files
committed
test: fix test fixture config injection and remove dead tests (anomalyco#210)
1 parent 14e538d commit a72d439

7 files changed

Lines changed: 81 additions & 909 deletions

File tree

‎docs/UPSTREAM-MERGE-LOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99

1010
合并流程和策略统一维护在 `docs/BRANDING.md` §9,此处只记录每次合并的关键元数据和值得注意的事项。
1111

12+
## 测试 fixture 配置注入分叉(2026-08-17)
13+
14+
**动机**:ellamaka 自研提交 `3452e46589`(2026-06-18 "refactor(config): remove opencode compatibility")移除 normal mode 项目级 `opencode.json`/`opencode.jsonc`/XDG config 加载,所有模式仅从 `~/.wopal/config/settings.jsonc`(ellamaka 路径)加载配置。但测试 fixture(`packages/opencode/test/fixture/fixture.ts`)与相关测试 helper 仍向 tmpdir 写项目级 `opencode.json` → 配置不生效 → LLM 请求打到真实 API 而非 mock server(Plan #210 修复的根因)。
15+
16+
**迁移**:测试配置注入已迁移到全局 settings 路径(`$WOPAL_HOME/config/settings.jsonc`,测试环境 WOPAL_HOME 由 `test/preload.ts` 按 PID 隔离到 `os.tmpdir()/opencode-test-data-<pid>`),引擎 normal mode 实际读取该路径。涉及文件:`test/fixture/fixture.ts`(`writeGlobalTestConfig`/`removeGlobalTestConfig`)、`test/session/prompt.test.ts`、`test/session/llm-native-recorded.test.ts`。同时删除一批测试项目级 config 加载机制的死测试(`test/config/config.test.ts`、`test/server/httpapi-session.test.ts`)。
17+
18+
**上游合并时的预期冲突点与处理原则**:
19+
1. `test/fixture/fixture.ts`:上游改动可能涉及 tmpdir 与 config 写入逻辑。处理原则:**保留 ellamaka 全局 settings 路径写入**,不回到项目级 `opencode.json` 写入。
20+
2. `test/config/config.test.ts`:上游若恢复项目级 config 加载测试,与 ellamaka 产品决策(仅全局 settings 路径)冲突,需按 ellamaka 语义调整而非盲目合并。
21+
3. 其他测试文件对 `tmpdir({ config })` / `tmpdirScoped({ config })` 的使用:保持迁移后的全局 settings 语义。
22+
1223
## Remotes
1324

1425
| Remote | URL | 用途 |

‎packages/opencode/test/AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test("example", async () => {
1919
### Options
2020

2121
- `git?: boolean` - Initialize a git repo with a root commit
22-
- `config?: Partial<Config.Info>` - Write an `opencode.json` config file
22+
- `config?: Partial<Config.Info>` - Write the config to the global settings path (`$WOPAL_HOME/config/settings.jsonc`, isolated per-PID by `test/preload.ts`). The engine loads this path in normal mode; project-level `opencode.json` is not loaded. The file is removed when the fixture scope ends, and only by the fixture that wrote it.
2323
- `init?: (dir: string) => Promise<T>` - Custom setup function, returns value accessible as `tmp.extra`
2424
- `dispose?: (dir: string) => Promise<T>` - Custom cleanup function
2525

0 commit comments

Comments
 (0)