diff --git a/codex-rs/app-server/tests/common/Cargo.toml b/codex-rs/app-server/tests/common/Cargo.toml index de58509f0d..12aeb95f47 100644 --- a/codex-rs/app-server/tests/common/Cargo.toml +++ b/codex-rs/app-server/tests/common/Cargo.toml @@ -7,6 +7,10 @@ license.workspace = true [lib] path = "lib.rs" +[[bin]] +name = "codex-app-server-test-notify-capture" +path = "notify_capture.rs" + [dependencies] anyhow = { workspace = true } base64 = { workspace = true } diff --git a/codex-rs/app-server/tests/common/notify_capture.rs b/codex-rs/app-server/tests/common/notify_capture.rs new file mode 100644 index 0000000000..846e37a300 --- /dev/null +++ b/codex-rs/app-server/tests/common/notify_capture.rs @@ -0,0 +1,22 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() -> anyhow::Result<()> { + let mut args = env::args_os(); + let _program = args.next(); + let output_path = PathBuf::from( + args.next() + .ok_or_else(|| anyhow::anyhow!("expected output path as first argument"))?, + ); + let payload = args + .next() + .ok_or_else(|| anyhow::anyhow!("expected payload as final argument"))?; + + let mut file = File::create(&output_path)?; + file.write_all(payload.to_string_lossy().as_bytes())?; + file.sync_all()?; + + Ok(()) +} diff --git a/codex-rs/app-server/tests/suite/v2/initialize.rs b/codex-rs/app-server/tests/suite/v2/initialize.rs index 6667f2fcce..7e4ab71867 100644 --- a/codex-rs/app-server/tests/suite/v2/initialize.rs +++ b/codex-rs/app-server/tests/suite/v2/initialize.rs @@ -14,6 +14,7 @@ use codex_app_server_protocol::ThreadStartResponse; use codex_app_server_protocol::TurnStartParams; use codex_app_server_protocol::TurnStartResponse; use codex_app_server_protocol::UserInput as V2UserInput; +use codex_utils_cargo_bin::cargo_bin; use pretty_assertions::assert_eq; use serde_json::Value; use std::path::Path; @@ -192,27 +193,22 @@ async fn turn_start_notify_payload_includes_initialize_client_name() -> Result<( let responses = vec![create_final_assistant_message_sse_response("Done")?]; let server = create_mock_responses_server_sequence_unchecked(responses).await; let codex_home = TempDir::new()?; - let notify_script = codex_home.path().join("notify.py"); - std::fs::write( - ¬ify_script, - r#"from pathlib import Path -import sys - -payload_path = Path(__file__).with_name("notify.json") -payload_path.write_text(sys.argv[-1], encoding="utf-8") -"#, - )?; let notify_file = codex_home.path().join("notify.json"); - let notify_script = notify_script + let notify_capture = cargo_bin("codex-app-server-test-notify-capture")?; + let notify_capture = notify_capture .to_str() - .expect("notify script path should be valid UTF-8"); + .expect("notify capture path should be valid UTF-8"); + let notify_file_str = notify_file + .to_str() + .expect("notify file path should be valid UTF-8"); create_config_toml_with_extra( codex_home.path(), &server.uri(), "never", &format!( - "notify = [\"python3\", {}]", - toml_basic_string(notify_script) + "notify = [{}, {}]", + toml_basic_string(notify_capture), + toml_basic_string(notify_file_str) ), )?;