blob: c5104540f69fd5dbbd08cf7b0ccb305f5e587c6d [file] [log] [blame]
Jeff Vander Stoepbf372732021-02-18 09:39:46 +01001#![warn(
2 missing_debug_implementations,
3 missing_docs,
4 rust_2018_idioms,
5 unreachable_pub
6)]
7#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
8#![doc(test(
9 no_crate_inject,
10 attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
11))]
12
13//! Tokio and Futures based testing utilites
14
15pub mod io;
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
Elliott Hughes9dcb4412021-04-02 10:43:29 -070024/// [`tokio::runtime::Runtime::block_on`][runtime-block-on].
Jeff Vander Stoepbf372732021-02-18 09:39:46 +010025///
Elliott Hughes9dcb4412021-04-02 10:43:29 -070026/// [runtime-block-on]: https://docs.rs/tokio/1.3.0/tokio/runtime/struct.Runtime.html#method.block_on
Jeff Vander Stoepbf372732021-02-18 09:39:46 +010027pub 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}