From 5ba42268e892f4a10531a3eb2725ff20d2dea620 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Fri, 1 May 2026 14:17:01 -0700 Subject: [PATCH] test: make async cancellation test deterministic --- codex-rs/async-utils/src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/codex-rs/async-utils/src/lib.rs b/codex-rs/async-utils/src/lib.rs index bd880ae1fb..523a424343 100644 --- a/codex-rs/async-utils/src/lib.rs +++ b/codex-rs/async-utils/src/lib.rs @@ -34,6 +34,7 @@ where mod tests { use super::*; use pretty_assertions::assert_eq; + use std::future::pending; use std::time::Duration; use tokio::task; use tokio::time::sleep; @@ -58,12 +59,7 @@ mod tests { token_clone.cancel(); }); - let result = async { - sleep(Duration::from_millis(100)).await; - 7 - } - .or_cancel(&token) - .await; + let result = pending::().or_cancel(&token).await; cancel_handle.await.expect("cancel task panicked"); assert_eq!(Err(CancelErr::Cancelled), result);