diff options
Diffstat (limited to 'tests/time_sleep.rs')
-rw-r--r-- | tests/time_sleep.rs | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/tests/time_sleep.rs b/tests/time_sleep.rs index 20477d2..4174a73 100644 --- a/tests/time_sleep.rs +++ b/tests/time_sleep.rs @@ -168,6 +168,7 @@ async fn reset_sleep_to_past() { assert_ready!(sleep.poll()); } +#[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery #[test] #[should_panic] fn creating_sleep_outside_of_context() { @@ -188,10 +189,7 @@ async fn greater_than_max() { #[tokio::test] async fn short_sleeps() { - for i in 0..10000 { - if (i % 10) == 0 { - eprintln!("=== {}", i); - } + for _ in 0..10000 { tokio::time::sleep(std::time::Duration::from_millis(0)).await; } } @@ -236,22 +234,6 @@ async fn long_sleeps() { } #[tokio::test] -#[should_panic(expected = "Duration too far into the future")] -async fn very_long_sleeps() { - tokio::time::pause(); - - // Some platforms (eg macos) can't represent times this far in the future - if let Some(deadline) = tokio::time::Instant::now().checked_add(Duration::from_secs(1u64 << 62)) - { - tokio::time::sleep_until(deadline).await; - } else { - // make it pass anyway (we can't skip/ignore the test based on the - // result of checked_add) - panic!("Duration too far into the future (test ignored)") - } -} - -#[tokio::test] async fn reset_after_firing() { let timer = tokio::time::sleep(std::time::Duration::from_millis(1)); tokio::pin!(timer); @@ -333,18 +315,18 @@ async fn drop_from_wake() { tokio::time::pause(); - let mut lock = list.lock().unwrap(); + { + let mut lock = list.lock().unwrap(); - for _ in 0..100 { - let mut timer = Box::pin(tokio::time::sleep(Duration::from_millis(10))); + for _ in 0..100 { + let mut timer = Box::pin(tokio::time::sleep(Duration::from_millis(10))); - let _ = timer.as_mut().poll(&mut Context::from_waker(&arc_wake)); + let _ = timer.as_mut().poll(&mut Context::from_waker(&arc_wake)); - lock.push(timer); + lock.push(timer); + } } - drop(lock); - tokio::time::sleep(Duration::from_millis(11)).await; assert!( |