mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Make gRPC code-mode yield tests deterministic (#38321)
## What changed - Use a never-resolving promise when verifying that a session continues to enforce its yield limit after terminating a cell. - Use `yield_control()` to create the yielded cell in the notification-draining test instead of relying on timer scheduling. GitOrigin-RevId: 01cdaa94e5b8b5c89c6fa98c4bbdb28a690678e0
This commit is contained in:
committed by
copyberry
parent
902bd9e06b
commit
e0de12a126
@@ -877,8 +877,11 @@ async fn sessions_enforce_independent_yield_limits() -> Result<()> {
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
execute(&limited, request(r#"text("recovered");"#)).await?,
|
||||
text_response("2", "recovered")
|
||||
execute(&limited, request("await new Promise(() => {});")).await?,
|
||||
RuntimeResponse::Yielded {
|
||||
cell_id: cell_id("2"),
|
||||
content_items: Vec::new(),
|
||||
}
|
||||
);
|
||||
limited.shutdown().await.map_err(anyhow::Error::msg)?;
|
||||
other.shutdown().await.map_err(anyhow::Error::msg)?;
|
||||
|
||||
@@ -183,10 +183,7 @@ async fn completed_waits_drain_pending_notifications_before_returning() -> Resul
|
||||
.create_session(delegate.clone())
|
||||
.await
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let mut pending = request(
|
||||
r#"await new Promise(resolve => setTimeout(resolve, 25)); notify("notice"); text("done");"#,
|
||||
);
|
||||
pending.yield_time_ms = Some(/*value*/ 1);
|
||||
let pending = request(r#"yield_control(); notify("notice"); text("done");"#);
|
||||
let cell = session.execute(pending).await.map_err(anyhow::Error::msg)?;
|
||||
assert_eq!(
|
||||
cell.initial_response().await.map_err(anyhow::Error::msg)?,
|
||||
|
||||
Reference in New Issue
Block a user