Skip to content

Commit 4a55646

Browse files
chore: testing on freeform apply_patch (openai#5952)
## Summary Duplicates the tests in `apply_patch_cli.rs`, but tests the freeform apply_patch tool as opposed to the function call path. The good news is that all the tests pass with zero logical tests, with the exception of the heredoc, which doesn't really make sense in the freeform tool context anyway. @jif-oai since you wrote the original tests in openai#5557, I'd love your opinion on the right way to DRY these test cases between the two. Happy to set up a more sophisticated harness, but didn't want to go down the rabbit hole until we agreed on the right pattern ## Testing - [x] These are tests
1 parent 209af68 commit 4a55646

File tree

3 files changed

+1027
-0
lines changed

3 files changed

+1027
-0
lines changed

codex-rs/core/tests/common/test_codex.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ impl TestCodexHarness {
240240
.expect("output string")
241241
.to_string()
242242
}
243+
244+
pub async fn custom_tool_call_output(&self, call_id: &str) -> String {
245+
let bodies = self.request_bodies().await;
246+
custom_tool_call_output(&bodies, call_id)
247+
.get("output")
248+
.and_then(Value::as_str)
249+
.expect("output string")
250+
.to_string()
251+
}
252+
}
253+
254+
fn custom_tool_call_output<'a>(bodies: &'a [Value], call_id: &str) -> &'a Value {
255+
for body in bodies {
256+
if let Some(items) = body.get("input").and_then(Value::as_array) {
257+
for item in items {
258+
if item.get("type").and_then(Value::as_str) == Some("custom_tool_call_output")
259+
&& item.get("call_id").and_then(Value::as_str) == Some(call_id)
260+
{
261+
return item;
262+
}
263+
}
264+
}
265+
}
266+
panic!("custom_tool_call_output {call_id} not found");
243267
}
244268

245269
fn function_call_output<'a>(bodies: &'a [Value], call_id: &str) -> &'a Value {

0 commit comments

Comments
 (0)