| 121 | |
| 122 | #[tokio::test] |
| 123 | async fn runtime_shutdown() { |
| 124 | let rt = Runtime::new().unwrap(); |
| 125 | #[expect(clippy::async_yields_async)] |
| 126 | let task = rt |
| 127 | .spawn(async { |
| 128 | SpawnedTask::spawn(async { |
| 129 | let fut: Pending<()> = pending(); |
| 130 | fut.await; |
| 131 | unreachable!("should never return"); |
| 132 | }) |
| 133 | }) |
| 134 | .await |
| 135 | .unwrap(); |
| 136 | |
| 137 | // caller shutdown their DF runtime (e.g. timeout, error in caller, etc) |
| 138 | rt.shutdown_background(); |
| 139 | |
| 140 | // race condition |
| 141 | // poll occurs during shutdown (buffered stream poll calls, etc) |
| 142 | assert!(matches!( |
| 143 | task.join_unwind().await, |
| 144 | Err(e) if e.is_cancelled() |
| 145 | )); |
| 146 | } |
| 147 | |
| 148 | #[tokio::test] |
| 149 | #[should_panic(expected = "foo")] |