diff --git a/tokio/src/runtime/tests/task_combinations.rs b/tokio/src/runtime/tests/task_combinations.rs index 73a20d976..ca13c8c95 100644 --- a/tokio/src/runtime/tests/task_combinations.rs +++ b/tokio/src/runtime/tests/task_combinations.rs @@ -64,6 +64,7 @@ enum CombiAbortSource { AbortHandle, } +#[cfg(panic = "unwind")] #[test] fn test_combinations() { let mut rt = &[ diff --git a/tokio/src/sync/tests/atomic_waker.rs b/tokio/src/sync/tests/atomic_waker.rs index 989175a53..8a1201287 100644 --- a/tokio/src/sync/tests/atomic_waker.rs +++ b/tokio/src/sync/tests/atomic_waker.rs @@ -36,6 +36,7 @@ fn wake_without_register() { assert!(!waker.is_woken()); } +#[cfg(panic = "unwind")] #[test] #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn atomic_waker_panic_safe() { diff --git a/tokio/tests/io_panic.rs b/tokio/tests/io_panic.rs index 9b2bf6a3b..89e504f46 100644 --- a/tokio/tests/io_panic.rs +++ b/tokio/tests/io_panic.rs @@ -54,6 +54,7 @@ mod unix { } } +#[cfg(panic = "unwind")] #[test] fn read_buf_initialize_unfilled_to_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -69,6 +70,7 @@ fn read_buf_initialize_unfilled_to_panic_caller() -> Result<(), Box> Ok(()) } +#[cfg(panic = "unwind")] #[test] fn read_buf_advance_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -84,6 +86,7 @@ fn read_buf_advance_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn read_buf_set_filled_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -99,6 +102,7 @@ fn read_buf_set_filled_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn read_buf_put_slice_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -116,6 +120,7 @@ fn read_buf_put_slice_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn unsplit_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { diff --git a/tokio/tests/join_handle_panic.rs b/tokio/tests/join_handle_panic.rs index c25a5f885..94a1b6112 100644 --- a/tokio/tests/join_handle_panic.rs +++ b/tokio/tests/join_handle_panic.rs @@ -9,6 +9,7 @@ impl Drop for PanicsOnDrop { } } +#[cfg(panic = "unwind")] #[tokio::test] async fn test_panics_do_not_propagate_when_dropping_join_handle() { let join_handle = tokio::spawn(async move { PanicsOnDrop }); diff --git a/tokio/tests/net_panic.rs b/tokio/tests/net_panic.rs index 798076189..a7ce0afc0 100644 --- a/tokio/tests/net_panic.rs +++ b/tokio/tests/net_panic.rs @@ -10,6 +10,7 @@ mod support { } use support::panic::test_panic; +#[cfg(panic = "unwind")] #[test] fn udp_socket_from_std_panic_caller() -> Result<(), Box> { use std::net::SocketAddr; @@ -32,6 +33,7 @@ fn udp_socket_from_std_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn tcp_listener_from_std_panic_caller() -> Result<(), Box> { let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); @@ -50,6 +52,7 @@ fn tcp_listener_from_std_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn tcp_stream_from_std_panic_caller() -> Result<(), Box> { let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); @@ -163,6 +166,7 @@ fn unix_datagram_from_std_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] #[cfg(windows)] fn server_options_max_instances_panic_caller() -> Result<(), Box> { diff --git a/tokio/tests/rt_handle.rs b/tokio/tests/rt_handle.rs index 5d4b53f63..a571b98ea 100644 --- a/tokio/tests/rt_handle.rs +++ b/tokio/tests/rt_handle.rs @@ -3,6 +3,7 @@ use tokio::runtime::Runtime; +#[cfg(panic = "unwind")] #[test] fn basic_enter() { let rt1 = rt(); @@ -15,6 +16,7 @@ fn basic_enter() { drop(enter1); } +#[cfg(panic = "unwind")] #[test] #[should_panic] fn interleave_enter_different_rt() { @@ -28,6 +30,7 @@ fn interleave_enter_different_rt() { drop(enter2); } +#[cfg(panic = "unwind")] #[test] #[should_panic] fn interleave_enter_same_rt() { @@ -41,6 +44,7 @@ fn interleave_enter_same_rt() { drop(enter3); } +#[cfg(panic = "unwind")] #[test] #[cfg(not(target_os = "wasi"))] fn interleave_then_enter() { diff --git a/tokio/tests/rt_panic.rs b/tokio/tests/rt_panic.rs index 57f327481..5b5ee48a9 100644 --- a/tokio/tests/rt_panic.rs +++ b/tokio/tests/rt_panic.rs @@ -11,6 +11,7 @@ mod support { } use support::panic::test_panic; +#[cfg(panic = "unwind")] #[test] fn current_handle_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -23,6 +24,7 @@ fn current_handle_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn into_panic_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(move || { @@ -45,6 +47,7 @@ fn into_panic_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn builder_worker_threads_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -57,6 +60,7 @@ fn builder_worker_threads_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn builder_max_blocking_threads_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { diff --git a/tokio/tests/sync_panic.rs b/tokio/tests/sync_panic.rs index bcdaaae56..ae261f993 100644 --- a/tokio/tests/sync_panic.rs +++ b/tokio/tests/sync_panic.rs @@ -12,6 +12,7 @@ mod support { } use support::panic::test_panic; +#[cfg(panic = "unwind")] #[test] fn broadcast_channel_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -24,6 +25,7 @@ fn broadcast_channel_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn mutex_blocking_lock_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -40,6 +42,7 @@ fn mutex_blocking_lock_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn oneshot_blocking_recv_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -56,6 +59,7 @@ fn oneshot_blocking_recv_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn rwlock_with_max_readers_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -68,6 +72,7 @@ fn rwlock_with_max_readers_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn rwlock_blocking_read_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -84,6 +89,7 @@ fn rwlock_blocking_read_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn rwlock_blocking_write_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -100,6 +106,7 @@ fn rwlock_blocking_write_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn mpsc_bounded_channel_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -112,6 +119,7 @@ fn mpsc_bounded_channel_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn mpsc_bounded_receiver_blocking_recv_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -128,6 +136,7 @@ fn mpsc_bounded_receiver_blocking_recv_panic_caller() -> Result<(), Box Result<(), Box> { let panic_location_file = test_panic(|| { @@ -144,6 +153,7 @@ fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box Ok(()) } +#[cfg(panic = "unwind")] #[test] fn mpsc_unbounded_receiver_blocking_recv_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -160,6 +170,7 @@ fn mpsc_unbounded_receiver_blocking_recv_panic_caller() -> Result<(), Box Result<(), Box> { let panic_location_file = test_panic(|| { @@ -176,6 +187,7 @@ fn semaphore_merge_unrelated_owned_permits() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn semaphore_merge_unrelated_permits() -> Result<(), Box> { let panic_location_file = test_panic(|| { diff --git a/tokio/tests/task_blocking.rs b/tokio/tests/task_blocking.rs index 4594498a6..b9cce9a4a 100644 --- a/tokio/tests/task_blocking.rs +++ b/tokio/tests/task_blocking.rs @@ -289,6 +289,7 @@ async fn unawaited_blocking_task_wakes_paused_runtime() { ); } +#[cfg(panic = "unwind")] #[cfg(feature = "test-util")] #[tokio::test(start_paused = true)] async fn panicking_blocking_task_wakes_paused_runtime() { diff --git a/tokio/tests/task_panic.rs b/tokio/tests/task_panic.rs index 2ca21b1de..47f3d6f0f 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_panic.rs @@ -12,6 +12,7 @@ mod support { } use support::panic::test_panic; +#[cfg(panic = "unwind")] #[test] fn block_in_place_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -27,6 +28,7 @@ fn block_in_place_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn local_set_spawn_local_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -41,6 +43,7 @@ fn local_set_spawn_local_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn local_set_block_on_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -58,6 +61,7 @@ fn local_set_block_on_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn spawn_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -70,6 +74,7 @@ fn spawn_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn local_key_sync_scope_panic_caller() -> Result<(), Box> { tokio::task_local! { @@ -90,6 +95,7 @@ fn local_key_sync_scope_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn local_key_with_panic_caller() -> Result<(), Box> { tokio::task_local! { @@ -106,6 +112,7 @@ fn local_key_with_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn local_key_get_panic_caller() -> Result<(), Box> { tokio::task_local! { diff --git a/tokio/tests/time_panic.rs b/tokio/tests/time_panic.rs index 02b928bb8..2b8e09573 100644 --- a/tokio/tests/time_panic.rs +++ b/tokio/tests/time_panic.rs @@ -12,6 +12,7 @@ mod support { } use support::panic::test_panic; +#[cfg(panic = "unwind")] #[test] fn pause_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -29,6 +30,7 @@ fn pause_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn resume_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -45,6 +47,7 @@ fn resume_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn interval_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -57,6 +60,7 @@ fn interval_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn interval_at_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -69,6 +73,7 @@ fn interval_at_panic_caller() -> Result<(), Box> { Ok(()) } +#[cfg(panic = "unwind")] #[test] fn timeout_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { diff --git a/tokio/tests/time_pause.rs b/tokio/tests/time_pause.rs index 6251b4b82..2750fc5c8 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -36,6 +36,7 @@ async fn pause_time_in_main_threads() { tokio::time::pause(); } +#[cfg(panic = "unwind")] #[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn pause_time_in_spawn_threads() {