Skip to content

Commit

Permalink
Making sure that lock guards don't get dropped right away in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjay committed Jul 27, 2020
1 parent 72c4eda commit aaae6f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tokio/tests/sync_mutex.rs
Expand Up @@ -47,7 +47,7 @@ fn readiness() {
// But once g unlocks, we can acquire it
drop(g);
assert!(t2.is_woken());
assert_ready!(t2.poll());
let _g = assert_ready!(t2.poll());
}

/*
Expand Down Expand Up @@ -92,7 +92,7 @@ async fn aborted_future_1() {
// Try to lock mutex in a future that is aborted prematurely
timeout(Duration::from_millis(1u64), async move {
let mut iv = interval(Duration::from_millis(1000));
m2.lock().await;
let _g = m2.lock().await;
iv.tick().await;
iv.tick().await;
})
Expand All @@ -101,7 +101,7 @@ async fn aborted_future_1() {
}
// This should succeed as there is no lock left for the mutex.
timeout(Duration::from_millis(1u64), async move {
m1.lock().await;
let _g = m1.lock().await;
})
.await
.expect("Mutex is locked");
Expand All @@ -119,15 +119,15 @@ async fn aborted_future_2() {
let m2 = m1.clone();
// Try to lock mutex in a future that is aborted prematurely
timeout(Duration::from_millis(1u64), async move {
m2.lock().await;
let _g = m2.lock().await;
})
.await
.unwrap_err();
}
}
// This should succeed as there is no lock left for the mutex.
timeout(Duration::from_millis(1u64), async move {
m1.lock().await;
let _g = m1.lock().await;
})
.await
.expect("Mutex is locked");
Expand Down

0 comments on commit aaae6f1

Please sign in to comment.