mirror of
https://github.com/openai/codex.git
synced 2026-09-15 12:08:01 +00:00
Stabilize flaky Windows integration tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use app_test_support::McpProcess;
|
||||
use app_test_support::create_final_assistant_message_sse_response;
|
||||
use app_test_support::create_mock_responses_server_sequence;
|
||||
use app_test_support::create_mock_responses_server_sequence_unchecked;
|
||||
use app_test_support::create_shell_command_sse_response;
|
||||
use app_test_support::format_with_current_shell;
|
||||
@@ -228,7 +227,7 @@ async fn test_send_user_turn_changes_approval_policy_behavior() -> Result<()> {
|
||||
)?,
|
||||
create_final_assistant_message_sse_response("done 2")?,
|
||||
];
|
||||
let server = create_mock_responses_server_sequence(responses).await;
|
||||
let server = create_mock_responses_server_sequence_unchecked(responses).await;
|
||||
create_config_toml(&codex_home, &server.uri())?;
|
||||
|
||||
// Start MCP server and initialize.
|
||||
@@ -396,7 +395,7 @@ async fn test_send_user_turn_updates_sandbox_and_cwd_between_turns() -> Result<(
|
||||
)?,
|
||||
create_final_assistant_message_sse_response("done second")?,
|
||||
];
|
||||
let server = create_mock_responses_server_sequence(responses).await;
|
||||
let server = create_mock_responses_server_sequence_unchecked(responses).await;
|
||||
create_config_toml(&codex_home, &server.uri())?;
|
||||
|
||||
let mut mcp = McpProcess::new(&codex_home).await?;
|
||||
|
||||
@@ -685,7 +685,7 @@ async fn turn_start_exec_approval_toggle_v2() -> Result<()> {
|
||||
)?,
|
||||
create_final_assistant_message_sse_response("done 2")?,
|
||||
];
|
||||
let server = create_mock_responses_server_sequence(responses).await;
|
||||
let server = create_mock_responses_server_sequence_unchecked(responses).await;
|
||||
// Default approval is untrusted to force elicitation on first turn.
|
||||
create_config_toml(
|
||||
codex_home.as_path(),
|
||||
|
||||
@@ -185,8 +185,11 @@ pub async fn wait_for_event<F>(codex: &CodexThread, predicate: F) -> codex_core:
|
||||
where
|
||||
F: FnMut(&codex_core::protocol::EventMsg) -> bool,
|
||||
{
|
||||
use tokio::time::Duration;
|
||||
wait_for_event_with_timeout(codex, predicate, Duration::from_secs(1)).await
|
||||
#[cfg(target_os = "windows")]
|
||||
let wait_time = tokio::time::Duration::from_secs(3);
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let wait_time = tokio::time::Duration::from_secs(1);
|
||||
wait_for_event_with_timeout(codex, predicate, wait_time).await
|
||||
}
|
||||
|
||||
pub async fn wait_for_event_match<T, F>(codex: &CodexThread, matcher: F) -> T
|
||||
@@ -205,11 +208,14 @@ pub async fn wait_for_event_with_timeout<F>(
|
||||
where
|
||||
F: FnMut(&codex_core::protocol::EventMsg) -> bool,
|
||||
{
|
||||
use tokio::time::Duration;
|
||||
use tokio::time::timeout;
|
||||
#[cfg(target_os = "windows")]
|
||||
let min_wait_time = tokio::time::Duration::from_secs(10);
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let min_wait_time = tokio::time::Duration::from_secs(5);
|
||||
loop {
|
||||
// Allow a bit more time to accommodate async startup work (e.g. config IO, tool discovery)
|
||||
let ev = timeout(wait_time.max(Duration::from_secs(5)), codex.next_event())
|
||||
let ev = timeout(wait_time.max(min_wait_time), codex.next_event())
|
||||
.await
|
||||
.expect("timeout waiting for event")
|
||||
.expect("stream ended unexpectedly");
|
||||
|
||||
Reference in New Issue
Block a user