Skip to content

Commit 821abbb

Browse files
committed
Fix post-rebase test fixtures
1 parent ac736d7 commit 821abbb

9 files changed

Lines changed: 61 additions & 10 deletions

File tree

codex-rs/app-server/tests/suite/v2/mcp_server_status.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::borrow::Cow;
22
use std::collections::BTreeMap;
33
use std::collections::BTreeSet;
44
use std::sync::Arc;
5+
use std::sync::atomic::AtomicUsize;
6+
use std::sync::atomic::Ordering;
57
use std::time::Duration;
68

79
use anyhow::Result;
@@ -143,6 +145,13 @@ impl ServerHandler for McpStatusServer {
143145
#[derive(Clone)]
144146
struct SlowInventoryServer {
145147
tool_name: Arc<String>,
148+
calls: SlowInventoryCallCounts,
149+
}
150+
151+
#[derive(Clone, Default)]
152+
struct SlowInventoryCallCounts {
153+
resources: Arc<AtomicUsize>,
154+
resource_templates: Arc<AtomicUsize>,
146155
}
147156

148157
impl ServerHandler for SlowInventoryServer {
@@ -186,6 +195,7 @@ impl ServerHandler for SlowInventoryServer {
186195
_request: Option<PaginatedRequestParams>,
187196
_context: RequestContext<rmcp::service::RoleServer>,
188197
) -> Result<ListResourcesResult, rmcp::ErrorData> {
198+
self.calls.resources.fetch_add(1, Ordering::SeqCst);
189199
tokio::time::sleep(Duration::from_secs(2)).await;
190200
Ok(ListResourcesResult {
191201
resources: Vec::new(),
@@ -199,6 +209,7 @@ impl ServerHandler for SlowInventoryServer {
199209
_request: Option<PaginatedRequestParams>,
200210
_context: RequestContext<rmcp::service::RoleServer>,
201211
) -> Result<ListResourceTemplatesResult, rmcp::ErrorData> {
212+
self.calls.resource_templates.fetch_add(1, Ordering::SeqCst);
202213
tokio::time::sleep(Duration::from_secs(2)).await;
203214
Ok(ListResourceTemplatesResult {
204215
resource_templates: Vec::new(),
@@ -211,7 +222,8 @@ impl ServerHandler for SlowInventoryServer {
211222
#[tokio::test]
212223
async fn mcp_server_status_list_tools_and_auth_only_skips_slow_inventory_calls() -> Result<()> {
213224
let server = create_mock_responses_server_sequence_unchecked(Vec::new()).await;
214-
let (mcp_server_url, mcp_server_handle) = start_slow_inventory_mcp_server("lookup").await?;
225+
let (mcp_server_url, mcp_server_handle, calls) =
226+
start_slow_inventory_mcp_server("lookup").await?;
215227
let codex_home = TempDir::new()?;
216228
write_mock_responses_config_toml(
217229
codex_home.path(),
@@ -244,7 +256,7 @@ url = "{mcp_server_url}/mcp"
244256
})
245257
.await?;
246258
let response = timeout(
247-
Duration::from_millis(500),
259+
DEFAULT_READ_TIMEOUT,
248260
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
249261
)
250262
.await??;
@@ -260,6 +272,8 @@ url = "{mcp_server_url}/mcp"
260272
);
261273
assert_eq!(status.resources, Vec::new());
262274
assert_eq!(status.resource_templates, Vec::new());
275+
assert_eq!(calls.resources.load(Ordering::SeqCst), 0);
276+
assert_eq!(calls.resource_templates.load(Ordering::SeqCst), 0);
263277

264278
mcp_server_handle.abort();
265279
let _ = mcp_server_handle.await;
@@ -367,14 +381,19 @@ async fn start_mcp_server(tool_name: &str) -> Result<(String, JoinHandle<()>)> {
367381
Ok((format!("http://{addr}"), handle))
368382
}
369383

370-
async fn start_slow_inventory_mcp_server(tool_name: &str) -> Result<(String, JoinHandle<()>)> {
384+
async fn start_slow_inventory_mcp_server(
385+
tool_name: &str,
386+
) -> Result<(String, JoinHandle<()>, SlowInventoryCallCounts)> {
371387
let listener = TcpListener::bind("127.0.0.1:0").await?;
372388
let addr = listener.local_addr()?;
373389
let tool_name = Arc::new(tool_name.to_string());
390+
let calls = SlowInventoryCallCounts::default();
391+
let server_calls = calls.clone();
374392
let mcp_service = StreamableHttpService::new(
375393
move || {
376394
Ok(SlowInventoryServer {
377395
tool_name: Arc::clone(&tool_name),
396+
calls: server_calls.clone(),
378397
})
379398
},
380399
Arc::new(LocalSessionManager::default()),
@@ -386,5 +405,5 @@ async fn start_slow_inventory_mcp_server(tool_name: &str) -> Result<(String, Joi
386405
let _ = axum::serve(listener, router).await;
387406
});
388407

389-
Ok((format!("http://{addr}"), handle))
408+
Ok((format!("http://{addr}"), handle, calls))
390409
}

codex-rs/app-server/tests/suite/v2/turn_start.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ async fn turn_start_emits_thread_scoped_warning_notification_for_trimmed_skills(
501501
write_test_skill(codex_home.path(), "alpha-skill")?;
502502
write_test_skill(codex_home.path(), "beta-skill")?;
503503

504-
let mut mcp = McpProcess::new(codex_home.path()).await?;
504+
let home_dir = codex_home.path().to_string_lossy().to_string();
505+
let mut mcp = McpProcess::new_with_env(codex_home.path(), &[("HOME", Some(&home_dir))]).await?;
505506
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
506507

507508
let thread_req = mcp

codex-rs/config/src/config_toml.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ pub struct ConfigToml {
177177
#[serde(default = "default_allow_login_shell")]
178178
pub allow_login_shell: Option<bool>,
179179

180+
/// Optional absolute path to patched zsh used by the shell_zsh_fork feature.
181+
pub zsh_path: Option<AbsolutePathBuf>,
182+
180183
/// Sandbox mode to use.
181184
pub sandbox_mode: Option<SandboxMode>,
182185

codex-rs/config/src/hooks_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ fn hook_command_timeout_accepts_timeout_sec_alias() {
111111
parsed.hooks.pre_tool_use[0].hooks[0],
112112
HookHandlerConfig::Command {
113113
command: "python3 /tmp/pre.py".to_string(),
114+
command_windows: None,
114115
timeout_sec: Some(12),
115116
r#async: false,
116117
status_message: None,

codex-rs/core/config.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4978,6 +4978,14 @@
49784978
],
49794979
"default": null,
49804980
"description": "Windows-specific configuration."
4981+
},
4982+
"zsh_path": {
4983+
"allOf": [
4984+
{
4985+
"$ref": "#/definitions/AbsolutePathBuf"
4986+
}
4987+
],
4988+
"description": "Optional absolute path to patched zsh used by the shell_zsh_fork feature."
49814989
}
49824990
},
49834991
"title": "ConfigToml",

codex-rs/core/src/config/config_tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,6 +4489,25 @@ async fn default_zsh_path_sets_runtime_zsh_path() -> std::io::Result<()> {
44894489
Ok(())
44904490
}
44914491

4492+
#[tokio::test]
4493+
async fn configured_zsh_path_sets_runtime_zsh_path() -> std::io::Result<()> {
4494+
let codex_home = TempDir::new()?;
4495+
let configured_zsh_path = codex_home.path().join("configured-zsh");
4496+
4497+
let config = Config::load_from_base_config_with_overrides(
4498+
ConfigToml {
4499+
zsh_path: Some(configured_zsh_path.abs()),
4500+
..Default::default()
4501+
},
4502+
ConfigOverrides::default(),
4503+
codex_home.abs(),
4504+
)
4505+
.await?;
4506+
assert_eq!(config.zsh_path, Some(configured_zsh_path));
4507+
4508+
Ok(())
4509+
}
4510+
44924511
#[tokio::test]
44934512
async fn sqlite_home_defaults_to_codex_home_for_workspace_write() -> std::io::Result<()> {
44944513
let codex_home = TempDir::new()?;

codex-rs/core/src/config/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3207,7 +3207,9 @@ impl Config {
32073207
)
32083208
.await?;
32093209
let compact_prompt = compact_prompt.or(file_compact_prompt);
3210-
let zsh_path = default_zsh_path
3210+
let zsh_path = cfg
3211+
.zsh_path
3212+
.or(default_zsh_path)
32113213
.or_else(|| InstallContext::current().bundled_zsh_path())
32123214
.map(AbsolutePathBuf::into_path_buf);
32133215

codex-rs/core/src/session/turn.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ async fn run_sampling_request(
962962
return Err(CodexErr::ContextWindowExceeded);
963963
}
964964
context_window_compaction_retries += 1;
965-
let reset_client_session = run_auto_compact(
965+
run_auto_compact(
966966
&sess,
967967
&turn_context,
968968
client_session,
@@ -971,9 +971,6 @@ async fn run_sampling_request(
971971
CompactionPhase::MidTurn,
972972
)
973973
.await?;
974-
if reset_client_session {
975-
client_session.reset_websocket_session();
976-
}
977974
retries = 0;
978975
continue;
979976
}

codex-rs/hooks/src/engine/mod_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ Path(r"{marker_path}").write_text("done", encoding="utf-8")
337337
let request = PreToolUseRequest {
338338
session_id: ThreadId::new(),
339339
turn_id: "turn-1".to_string(),
340+
subagent: None,
340341
cwd: cwd(),
341342
transcript_path: None,
342343
model: "gpt-test".to_string(),

0 commit comments

Comments
 (0)