补充项目内路径形状用例(/ 写法与大小写变体)

- direct_tool_calls.rs:新增单测 tool_call_paths_normalize_separators_and_case,
  覆盖 relativize_project_root_paths 的 `/` 分隔符分支与大小写不敏感分支
  (Codex 上报的路径分隔符与盘符大小写不受我们控制,这两条分支此前没有用例覆盖)
This commit is contained in:
2026-09-15 18:36:18 +08:00
parent b395185580
commit 3169baa2eb
@@ -1277,4 +1277,35 @@ mod tests {
"回读必须按时间正序"
);
}
/// 判据:项目内路径的 `\` / `/` 两种写法与大小写变体都要落成同一份项目相对路径
/// (Codex 上报的路径分隔符与盘符大小写不受我们控制)。
#[test]
fn tool_call_paths_normalize_separators_and_case() {
let root = init_tool_call_project("tool-call-path-variants");
let native = root.path().to_string_lossy().to_string();
let variants = [native.replace('\\', "/"), native.to_ascii_uppercase()];
let mut paths = Vec::new();
for (index, variant) in variants.into_iter().enumerate() {
let call = direct_tool_call_from_item(
root.path(),
&json!({
"id": format!("item-path-variant-{index}"),
"type": "fileChange",
"changes": [{"path": format!("{variant}/game/src/y.ts"), "kind": "update"}],
"startedAtMs": 1000,
}),
"turn-1",
false,
1000,
)
.expect("variant path tool call");
paths.push(call.detail.changes[0].path.clone());
}
assert_eq!(paths[0], "game/src/y.ts", "`/` 写法同样要落成项目相对路径");
assert_eq!(
paths[1], "game/src/y.ts",
"大小写变体同样要落成项目相对路径"
);
}
}