2019-08-10 00:07:57 +09:00
|
|
|
#![warn(
|
2019-05-14 10:27:36 -07:00
|
|
|
missing_debug_implementations,
|
2019-08-11 04:28:52 +09:00
|
|
|
missing_docs,
|
|
|
|
|
rust_2018_idioms,
|
|
|
|
|
unreachable_pub
|
2019-05-14 10:27:36 -07:00
|
|
|
)]
|
2019-09-19 15:50:12 +09:00
|
|
|
#![doc(test(
|
|
|
|
|
no_crate_inject,
|
|
|
|
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
|
|
|
|
))]
|
2019-04-23 23:17:57 -04:00
|
|
|
|
2021-07-01 02:06:56 +09:00
|
|
|
//! Tokio and Futures based testing utilities
|
2019-04-23 23:17:57 -04:00
|
|
|
|
2019-07-11 14:41:37 -07:00
|
|
|
pub mod io;
|
2019-11-21 23:28:39 -08:00
|
|
|
|
2019-04-23 23:17:57 -04:00
|
|
|
mod macros;
|
|
|
|
|
pub mod task;
|
2019-05-03 20:43:40 -07:00
|
|
|
|
2019-08-13 21:10:26 -07:00
|
|
|
/// Runs the provided future, blocking the current thread until the
|
|
|
|
|
/// future completes.
|
|
|
|
|
///
|
|
|
|
|
/// For more information, see the documentation for
|
2021-03-10 16:04:08 -05:00
|
|
|
/// [`tokio::runtime::Runtime::block_on`][runtime-block-on].
|
2019-08-13 21:10:26 -07:00
|
|
|
///
|
2021-03-10 16:04:08 -05:00
|
|
|
/// [runtime-block-on]: https://docs.rs/tokio/1.3.0/tokio/runtime/struct.Runtime.html#method.block_on
|
2019-08-13 21:10:26 -07:00
|
|
|
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
|
2019-11-01 13:18:52 -07:00
|
|
|
use tokio::runtime;
|
2019-08-13 21:10:26 -07:00
|
|
|
|
2020-10-12 13:44:54 -04:00
|
|
|
let rt = runtime::Builder::new_current_thread()
|
2019-11-21 23:28:39 -08:00
|
|
|
.enable_all()
|
|
|
|
|
.build()
|
|
|
|
|
.unwrap();
|
2019-11-01 13:18:52 -07:00
|
|
|
|
|
|
|
|
rt.block_on(future)
|
2019-05-03 20:43:40 -07:00
|
|
|
}
|