Lightweight coding agent that runs in your terminal
Rust
Fixes mcp elicitation test that fails for me when run locally (#8020)
Eric Trautd9554c8191c7
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lockindex dbb195a85d..707fd9d430 100644--- a/codex-rs/Cargo.lock+++ b/codex-rs/Cargo.lock@@ -1395,7 +1395,6 @@ dependencies = ["tokio-util","tracing","tracing-subscriber",- "which",][[package]]diff --git a/codex-rs/core/src/auth.rs b/codex-rs/core/src/auth.rsindex 933c80548a..8b44481060 100644--- a/codex-rs/core/src/auth.rs+++ b/codex-rs/core/src/auth.rs@@ -32,8 +32,10 @@ use crate::token_data::parse_id_token;use crate::util::try_parse_error_message;use codex_client::CodexHttpClient;use codex_protocol::account::PlanType as AccountPlanType;+#[cfg(any(test, feature = "test-support"))]use once_cell::sync::Lazy;use serde_json::Value;+#[cfg(any(test, feature = "test-support"))]use tempfile::TempDir;use thiserror::Error;diff --git a/codex-rs/exec-server/Cargo.toml b/codex-rs/exec-server/Cargo.tomlindex a0bd534934..4f8df05dbe 100644--- a/codex-rs/exec-server/Cargo.toml+++ b/codex-rs/exec-server/Cargo.toml@@ -61,4 +61,3 @@ exec_server_test_support = { workspace = true }maplit = { workspace = true }pretty_assertions = { workspace = true }tempfile = { workspace = true }-which = { workspace = true }diff --git a/codex-rs/exec-server/tests/suite/accept_elicitation.rs b/codex-rs/exec-server/tests/suite/accept_elicitation.rsindex 9632800d69..b703eaf4a7 100644--- a/codex-rs/exec-server/tests/suite/accept_elicitation.rs+++ b/codex-rs/exec-server/tests/suite/accept_elicitation.rs@@ -24,6 +24,7 @@ use serde_json::json;use std::os::unix::fs::PermissionsExt;use std::os::unix::fs::symlink;use tempfile::TempDir;+use tokio::process::Command;/// Verify that when using a read-only sandbox and an execpolicy that prompts,/// the proper elicitation is sent. Upon auto-approving the elicitation, the@@ -53,11 +54,11 @@ prefix_rule(// Create an MCP client that approves expected elicitation messages.let project_root = TempDir::new()?;- let git = which::which("git")?;let project_root_path = project_root.path().canonicalize().unwrap();+ let git_path = resolve_git_path().await?;let expected_elicitation_message = format!("Allow agent to run `{} init .` in `{}`?",- git.display(),+ git_path,project_root_path.display());let elicitation_requests: Arc<Mutex<Vec<CreateElicitationRequestParam>>> = Default::default();@@ -175,3 +176,23 @@ fn ensure_codex_cli() -> Result<PathBuf> {Ok(codex_cli)}++async fn resolve_git_path() -> Result<String> {+ let git = Command::new("bash")+ .arg("-lc")+ .arg("command -v git")+ .output()+ .await+ .context("failed to resolve git via login shell")?;+ ensure!(+ git.status.success(),+ "failed to resolve git via login shell: {}",+ String::from_utf8_lossy(&git.stderr)+ );+ let git_path = String::from_utf8(git.stdout)+ .context("git path was not valid utf8")?+ .trim()+ .to_string();+ ensure!(!git_path.is_empty(), "git path should not be empty");+ Ok(git_path)+}