mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
strong tests
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use codex_core::features::Feature;
|
||||
use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::Op;
|
||||
@@ -59,6 +57,13 @@ fn long_running_local_shell_call_with_output() -> Vec<&'static str> {
|
||||
}
|
||||
}
|
||||
|
||||
fn saw_partial_output(call_id: &str, event: &EventMsg) -> bool {
|
||||
let EventMsg::ExecCommandOutputDelta(delta) = event else {
|
||||
return false;
|
||||
};
|
||||
delta.call_id == call_id && String::from_utf8_lossy(&delta.chunk).contains("partial output")
|
||||
}
|
||||
|
||||
fn assert_aborted_output(output: &str) {
|
||||
let normalized_output = output.replace("\r\n", "\n").replace('\r', "\n");
|
||||
let normalized_output = normalized_output.trim_end_matches('\n');
|
||||
@@ -188,8 +193,7 @@ async fn interrupt_tool_records_history_entries() {
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::ExecCommandBegin(_))).await;
|
||||
|
||||
tokio::time::sleep(Duration::from_secs_f32(0.1)).await;
|
||||
wait_for_event(&codex, |ev| saw_partial_output(call_id, ev)).await;
|
||||
codex.submit(Op::Interrupt).await.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnAborted(_))).await;
|
||||
@@ -264,7 +268,7 @@ async fn interrupt_shell_records_partial_output() {
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::ExecCommandBegin(_))).await;
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
wait_for_event(&codex, |ev| saw_partial_output(call_id, ev)).await;
|
||||
codex.submit(Op::Interrupt).await.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnAborted(_))).await;
|
||||
@@ -323,7 +327,7 @@ async fn interrupt_local_shell_records_partial_output() {
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::ExecCommandBegin(_))).await;
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
wait_for_event(&codex, |ev| saw_partial_output(call_id, ev)).await;
|
||||
codex.submit(Op::Interrupt).await.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnAborted(_))).await;
|
||||
@@ -398,7 +402,7 @@ async fn interrupt_unified_exec_records_partial_output() {
|
||||
.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::ExecCommandBegin(_))).await;
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
wait_for_event(&codex, |ev| saw_partial_output(call_id, ev)).await;
|
||||
codex.submit(Op::Interrupt).await.unwrap();
|
||||
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnAborted(_))).await;
|
||||
|
||||
@@ -137,7 +137,7 @@ fn otlp_http_exporter_sends_metrics_to_collector() -> Result<()> {
|
||||
let (tx, rx) = mpsc::channel::<Vec<CapturedRequest>>();
|
||||
let server = thread::spawn(move || {
|
||||
let mut captured = Vec::new();
|
||||
let deadline = Instant::now() + Duration::from_secs(3);
|
||||
let deadline = Instant::now() + Duration::from_secs(12);
|
||||
|
||||
while Instant::now() < deadline {
|
||||
match listener.accept() {
|
||||
@@ -150,6 +150,7 @@ fn otlp_http_exporter_sends_metrics_to_collector() -> Result<()> {
|
||||
content_type: headers.get("content-type").cloned(),
|
||||
body,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => {
|
||||
|
||||
Reference in New Issue
Block a user