File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,18 @@ pub async fn init() -> Result<()> {
7474 Ok ( ( ) )
7575}
7676
77+ /// Initialize the test environment synchronously.
78+ ///
79+ /// This function creates its own tokio runtime and must be called from
80+ /// synchronous code only (e.g., at the start of a `#[test]` function).
81+ ///
82+ /// **Do not call this from inside an async function or tokio runtime** -
83+ /// it will panic. If you're already in an async context, use `init()` directly.
7784pub fn init_sync ( ) -> Result < ( ) > {
78- if let Ok ( handle) = tokio:: runtime:: Handle :: try_current ( ) {
79- handle. block_on ( init ( ) )
80- } else {
81- tokio:: runtime:: Runtime :: new ( ) ?. block_on ( init ( ) )
82- }
85+ tokio:: runtime:: Builder :: new_current_thread ( )
86+ . enable_all ( )
87+ . build ( ) ?
88+ . block_on ( init ( ) )
8389}
8490
8591async fn ensure_region_split (
You can’t perform that action at this time.
0 commit comments