tokio-test-shutdown-timeout 0.0.2

Tokio test attribute with a shutdown timeout
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 15.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 274.15 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • luryus

tokio-test-shutdown-timeout

A wrapper for #[tokio::test] that allows specifying a shutdown timeout.

Useful in situations where normal tokio tests hang because dropping the tokio runtime waits forever for all tasks to finish.

Usage

#[tokio_test_shutdown_timeout::test(1)]
#[should_panic]
async fn minimal_async_test() {

    // Start a forever-running blocking tokio task
    tokio::task::spawn_blocking(|| thread::sleep(Duration::MAX));

    // panic to fail the test
    panic!();
    
    // Normal tokio::test would block here, as dropping the tokio runtime
    // blocks until all tasks quit, and we have a task that never quits.
    // This custom version uses tokio's shutdown_timeout to avoid the deadlock.
}