Skip to main content

coven_domain/joining/
test_runtime.rs

1/// Run a joining test body on a thread with room for the flow's poll frames.
2///
3/// The joining futures are not `Send`, so the current-thread runtime moves to
4/// the configured thread rather than moving the future to a Tokio worker.
5pub fn on_a_deep_stack<Body, Fut>(body: Body)
6where
7    Body: FnOnce() -> Fut + Send + 'static,
8    Fut: std::future::Future<Output = ()>,
9{
10    std::thread::Builder::new()
11        .stack_size(64 * 1024 * 1024)
12        .spawn(move || {
13            tokio::runtime::Builder::new_current_thread()
14                .enable_all()
15                .build()
16                .expect("build the test runtime")
17                .block_on(body());
18        })
19        .expect("spawn the test thread")
20        .join()
21        .unwrap_or_else(|payload| std::panic::resume_unwind(payload));
22}