Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions codex-rs/core/tests/suite/shell_command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

use anyhow::Result;
use codex_core::features::Feature;
use core_test_support::assert_regex_match;
Expand All @@ -15,6 +17,10 @@ use core_test_support::test_codex::test_codex;
use serde_json::json;
use test_case::test_case;

/// Use this timeout if, empirically, a test seems to need more time than the
/// default.
const MEDIUM_TIMEOUT: Duration = Duration::from_secs(5);

fn shell_responses_with_timeout(
call_id: &str,
command: &str,
Expand Down Expand Up @@ -70,11 +76,11 @@ async fn mount_shell_responses_with_timeout(
call_id: &str,
command: &str,
login: Option<bool>,
timeout_ms: i64,
timeout: Duration,
) {
mount_sse_sequence(
harness.server(),
shell_responses_with_timeout(call_id, command, login, timeout_ms),
shell_responses_with_timeout(call_id, command, login, timeout.as_millis() as i64),
)
.await;
}
Expand Down Expand Up @@ -209,7 +215,14 @@ async fn shell_command_times_out_with_timeout_ms() -> anyhow::Result<()> {
} else {
"sleep 5"
};
mount_shell_responses_with_timeout(&harness, call_id, command, None, 200).await;
mount_shell_responses_with_timeout(
&harness,
call_id,
command,
None,
Duration::from_millis(200),
)
.await;
harness
.submit("run a long command with a short timeout")
.await?;
Expand Down Expand Up @@ -240,11 +253,12 @@ async fn unicode_output(login: bool) -> anyhow::Result<()> {
.await?;

let call_id = "unicode_output";
mount_shell_responses(
mount_shell_responses_with_timeout(
&harness,
call_id,
"git -c alias.say='!printf \"%s\" \"naïve_café\"' say",
Some(login),
MEDIUM_TIMEOUT,
)
.await;
harness.submit("run the command without login").await?;
Expand All @@ -269,11 +283,12 @@ async fn unicode_output_with_newlines(login: bool) -> anyhow::Result<()> {
.await?;

let call_id = "unicode_output";
mount_shell_responses(
mount_shell_responses_with_timeout(
&harness,
call_id,
"echo 'line1\nnaïve café\nline3'",
Some(login),
MEDIUM_TIMEOUT,
)
.await;
harness.submit("run the command without login").await?;
Expand Down
Loading