1#![warn(
2 missing_debug_implementations,
3 missing_docs,
4 rust_2018_idioms,
5 unreachable_pub
6)]
7#![doc(test(
8 no_crate_inject,
9 attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
10))]
11
12//! Tokio and Futures based testing utilities
13
14pub mod io;
15pub mod stream_mock;
16
17mod macros;
18pub mod task;
19
20/// Runs the provided future, blocking the current thread until the
21/// future completes.
22///
23/// For more information, see the documentation for
24/// [`tokio::runtime::Runtime::block_on`][runtime-block-on].
25///
26/// [runtime-block-on]: https://docs.rs/tokio/1.3.0/tokio/runtime/struct.Runtime.html#method.block_on
27pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
28 use tokio::runtime;
29
30 let rt = runtime::Builder::new_current_thread()
31 .enable_all()
32 .build()
33 .unwrap();
34
35 rt.block_on(future)
36}
37