From 7a12177cce9825ef4e93f5fc1ac822c42d020429 Mon Sep 17 00:00:00 2001 From: Abutalib Aghayev Date: Sat, 12 Nov 2022 15:03:36 -0500 Subject: [PATCH] move panic functions to their file --- tokio/tests/task_id.rs | 35 ----------------------------------- tokio/tests/task_panic.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/tokio/tests/task_id.rs b/tokio/tests/task_id.rs index fe6fe930f74..7dd884ced57 100644 --- a/tokio/tests/task_id.rs +++ b/tokio/tests/task_id.rs @@ -12,12 +12,6 @@ use tokio::runtime::{Builder, Runtime}; use tokio::sync::oneshot; use tokio::task::{self, Id, LocalSet}; -mod support { - pub mod panic; -} -#[cfg(not(tokio_wasi))] -use support::panic::test_panic; - #[tokio::test(flavor = "current_thread")] async fn task_id_spawn() { tokio::spawn(async { println!("task id: {}", task::id()) }) @@ -271,32 +265,3 @@ async fn task_id_block_in_place_block_on_spawn() { .await .unwrap(); } - -#[cfg(not(tokio_wasi))] -#[test] -fn task_id_outside_task_panic_caller() -> Result<(), Box> { - let panic_location_file = test_panic(|| { - let _ = task::id(); - }); - - // The panic location should be in this file - assert_eq!(&panic_location_file.unwrap(), file!()); - - Ok(()) -} - -#[cfg(not(tokio_wasi))] -#[test] -fn task_id_inside_block_on_panic_caller() -> Result<(), Box> { - let panic_location_file = test_panic(|| { - let rt = Runtime::new().unwrap(); - rt.block_on(async { - task::id(); - }); - }); - - // The panic location should be in this file - assert_eq!(&panic_location_file.unwrap(), file!()); - - Ok(()) -} diff --git a/tokio/tests/task_panic.rs b/tokio/tests/task_panic.rs index e4cedce2798..7f26a1ee33e 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_panic.rs @@ -121,3 +121,30 @@ fn local_key_get_panic_caller() -> Result<(), Box> { Ok(()) } + +#[test] +fn task_id_outside_task_panic_caller() -> Result<(), Box> { + let panic_location_file = test_panic(|| { + let _ = task::id(); + }); + + // The panic location should be in this file + assert_eq!(&panic_location_file.unwrap(), file!()); + + Ok(()) +} + +#[test] +fn task_id_inside_block_on_panic_caller() -> Result<(), Box> { + let panic_location_file = test_panic(|| { + let rt = Runtime::new().unwrap(); + rt.block_on(async { + task::id(); + }); + }); + + // The panic location should be in this file + assert_eq!(&panic_location_file.unwrap(), file!()); + + Ok(()) +}