diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b79ec21c..60a962f8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,6 +148,34 @@ jobs: cargo nextest run --workspace --all-features cargo test --doc --workspace --all-features + test-workspace-all-features-panic-abort: + needs: basics + name: test all crates in the workspace with all features and panic=abort + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - windows-latest + - ubuntu-latest + - macos-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust ${{ env.rust_nightly }} + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.rust_nightly }} + - name: Install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + + - uses: Swatinem/rust-cache@v2 + + - name: test all --all-features panic=abort + run: | + set -euxo pipefail + RUSTFLAGS="$RUSTFLAGS -C panic=abort -Zpanic-abort-tests" cargo nextest run --workspace --exclude tokio-macros --exclude tests-build --all-features --tests + test-integration-tests-per-feature: needs: basics name: Run integration tests for each feature diff --git a/tokio-stream/tests/stream_panic.rs b/tokio-stream/tests/stream_panic.rs index 22c1c2080..6ec737083 100644 --- a/tokio-stream/tests/stream_panic.rs +++ b/tokio-stream/tests/stream_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "time", not(target_os = "wasi")))] // Wasi does not support panic recovery +#![cfg(panic = "unwind")] use parking_lot::{const_mutex, Mutex}; use std::error::Error; diff --git a/tokio-util/tests/panic.rs b/tokio-util/tests/panic.rs index e4fcb47ef..853f132fc 100644 --- a/tokio-util/tests/panic.rs +++ b/tokio-util/tests/panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery +#![cfg(panic = "unwind")] use parking_lot::{const_mutex, Mutex}; use std::error::Error; @@ -76,7 +77,6 @@ fn poll_sender_send_item_panic_caller() -> Result<(), Box> { } #[test] - fn local_pool_handle_new_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { let _ = LocalPoolHandle::new(0); @@ -89,7 +89,6 @@ fn local_pool_handle_new_panic_caller() -> Result<(), Box> { } #[test] - fn local_pool_handle_spawn_pinned_by_idx_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { let rt = basic(); diff --git a/tokio-util/tests/spawn_pinned.rs b/tokio-util/tests/spawn_pinned.rs index 9eeeecfb0..e05b4095e 100644 --- a/tokio-util/tests/spawn_pinned.rs +++ b/tokio-util/tests/spawn_pinned.rs @@ -71,6 +71,7 @@ async fn can_spawn_multiple_futures() { /// A panic in the spawned task causes the join handle to return an error. /// But, you can continue to spawn tasks. #[tokio::test] +#[cfg(panic = "unwind")] async fn task_panic_propagates() { let pool = task::LocalPoolHandle::new(1); @@ -95,6 +96,7 @@ async fn task_panic_propagates() { /// A panic during task creation causes the join handle to return an error. /// But, you can continue to spawn tasks. #[tokio::test] +#[cfg(panic = "unwind")] async fn callback_panic_does_not_kill_worker() { let pool = task::LocalPoolHandle::new(1); diff --git a/tokio-util/tests/time_delay_queue.rs b/tokio-util/tests/time_delay_queue.rs index 9b7b6cc85..6616327d4 100644 --- a/tokio-util/tests/time_delay_queue.rs +++ b/tokio-util/tests/time_delay_queue.rs @@ -805,6 +805,7 @@ async fn item_expiry_greater_than_wheel() { #[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")] #[tokio::test(start_paused = true)] +#[cfg(panic = "unwind")] async fn remove_after_compact() { let now = Instant::now(); let mut queue = DelayQueue::new(); @@ -822,6 +823,7 @@ async fn remove_after_compact() { #[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")] #[tokio::test(start_paused = true)] +#[cfg(panic = "unwind")] async fn remove_after_compact_poll() { let now = Instant::now(); let mut queue = task::spawn(DelayQueue::new()); diff --git a/tokio/src/runtime/tests/task_combinations.rs b/tokio/src/runtime/tests/task_combinations.rs index ca13c8c95..0f99ed662 100644 --- a/tokio/src/runtime/tests/task_combinations.rs +++ b/tokio/src/runtime/tests/task_combinations.rs @@ -64,8 +64,8 @@ enum CombiAbortSource { AbortHandle, } -#[cfg(panic = "unwind")] #[test] +#[cfg_attr(panic = "abort", ignore)] fn test_combinations() { let mut rt = &[ CombiRuntime::CurrentThread, diff --git a/tokio/tests/io_panic.rs b/tokio/tests/io_panic.rs index 89e504f46..b2cbad275 100644 --- a/tokio/tests/io_panic.rs +++ b/tokio/tests/io_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery +#![cfg(panic = "unwind")] use std::task::{Context, Poll}; use std::{error::Error, pin::Pin}; @@ -54,7 +55,6 @@ mod unix { } } -#[cfg(panic = "unwind")] #[test] fn read_buf_initialize_unfilled_to_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -70,7 +70,6 @@ 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(|| { @@ -86,7 +85,6 @@ 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(|| { @@ -102,7 +100,6 @@ 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(|| { @@ -120,7 +117,6 @@ 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 94a1b6112..248d5702f 100644 --- a/tokio/tests/join_handle_panic.rs +++ b/tokio/tests/join_handle_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery +#![cfg(panic = "unwind")] struct PanicsOnDrop; @@ -9,7 +10,6 @@ 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 81c9df55e..9d6e87d9a 100644 --- a/tokio/tests/net_panic.rs +++ b/tokio/tests/net_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] +#![cfg(panic = "unwind")] use std::error::Error; use tokio::net::{TcpListener, TcpStream}; @@ -10,7 +11,6 @@ mod support { } use support::panic::test_panic; -#[cfg(panic = "unwind")] #[test] fn udp_socket_from_std_panic_caller() -> Result<(), Box> { use std::net::SocketAddr; @@ -33,7 +33,6 @@ 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(); @@ -52,7 +51,6 @@ 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(); @@ -166,7 +164,6 @@ 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/process_issue_2174.rs b/tokio/tests/process_issue_2174.rs index 5ee9dc0a4..2f8c73a58 100644 --- a/tokio/tests/process_issue_2174.rs +++ b/tokio/tests/process_issue_2174.rs @@ -17,6 +17,7 @@ use tokio::time; use tokio_test::assert_err; #[tokio::test] +#[cfg_attr(panic = "abort", ignore)] async fn issue_2174() { let mut child = Command::new("sleep") .arg("2") diff --git a/tokio/tests/rt_handle.rs b/tokio/tests/rt_handle.rs index a571b98ea..92fa777e3 100644 --- a/tokio/tests/rt_handle.rs +++ b/tokio/tests/rt_handle.rs @@ -3,8 +3,8 @@ use tokio::runtime::Runtime; -#[cfg(panic = "unwind")] #[test] +#[cfg_attr(panic = "abort", ignore)] fn basic_enter() { let rt1 = rt(); let rt2 = rt(); @@ -16,9 +16,9 @@ fn basic_enter() { drop(enter1); } -#[cfg(panic = "unwind")] #[test] #[should_panic] +#[cfg_attr(panic = "abort", ignore)] fn interleave_enter_different_rt() { let rt1 = rt(); let rt2 = rt(); @@ -30,9 +30,9 @@ fn interleave_enter_different_rt() { drop(enter2); } -#[cfg(panic = "unwind")] #[test] #[should_panic] +#[cfg_attr(panic = "abort", ignore)] fn interleave_enter_same_rt() { let rt1 = rt(); @@ -44,9 +44,9 @@ fn interleave_enter_same_rt() { drop(enter3); } -#[cfg(panic = "unwind")] #[test] #[cfg(not(target_os = "wasi"))] +#[cfg_attr(panic = "abort", ignore)] fn interleave_then_enter() { let _ = std::panic::catch_unwind(|| { let rt1 = rt(); diff --git a/tokio/tests/rt_panic.rs b/tokio/tests/rt_panic.rs index 5b5ee48a9..ecaf977c8 100644 --- a/tokio/tests/rt_panic.rs +++ b/tokio/tests/rt_panic.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery +#![cfg(panic = "unwind")] use futures::future; use std::error::Error; @@ -11,7 +12,6 @@ mod support { } use support::panic::test_panic; -#[cfg(panic = "unwind")] #[test] fn current_handle_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -24,7 +24,6 @@ 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 || { @@ -47,7 +46,6 @@ 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(|| { @@ -60,7 +58,6 @@ 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/signal_panic.rs b/tokio/tests/signal_panic.rs index ce1ec3e4a..6b662e54b 100644 --- a/tokio/tests/signal_panic.rs +++ b/tokio/tests/signal_panic.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(panic = "unwind")] use std::error::Error; use tokio::runtime::Builder; diff --git a/tokio/tests/sync_panic.rs b/tokio/tests/sync_panic.rs index ae261f993..41bf08500 100644 --- a/tokio/tests/sync_panic.rs +++ b/tokio/tests/sync_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] +#![cfg(panic = "unwind")] use std::{error::Error, sync::Arc}; use tokio::{ @@ -12,7 +13,6 @@ mod support { } use support::panic::test_panic; -#[cfg(panic = "unwind")] #[test] fn broadcast_channel_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -25,7 +25,6 @@ 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(|| { @@ -42,7 +41,6 @@ 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(|| { @@ -59,7 +57,6 @@ 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(|| { @@ -72,7 +69,6 @@ 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(|| { @@ -89,7 +85,6 @@ 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(|| { @@ -106,7 +101,6 @@ 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(|| { @@ -119,7 +113,6 @@ 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(|| { @@ -136,7 +129,6 @@ fn mpsc_bounded_receiver_blocking_recv_panic_caller() -> Result<(), Box Result<(), Box> { let panic_location_file = test_panic(|| { @@ -153,7 +145,6 @@ 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(|| { @@ -170,7 +161,6 @@ fn mpsc_unbounded_receiver_blocking_recv_panic_caller() -> Result<(), Box Result<(), Box> { let panic_location_file = test_panic(|| { @@ -187,7 +177,6 @@ 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_panic.rs b/tokio/tests/task_panic.rs index eb302d632..8b4de2ada 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] +#![cfg(panic = "unwind")] use futures::future; use std::error::Error; @@ -11,7 +12,6 @@ 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,7 +27,6 @@ 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(|| { @@ -42,7 +41,6 @@ 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(|| { @@ -60,7 +58,6 @@ 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(|| { @@ -73,7 +70,6 @@ fn spawn_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(panic = "unwind")] #[test] fn local_key_sync_scope_panic_caller() -> Result<(), Box> { tokio::task_local! { @@ -94,7 +90,6 @@ 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! { @@ -111,7 +106,6 @@ 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 0532812d3..8a997f045 100644 --- a/tokio/tests/time_panic.rs +++ b/tokio/tests/time_panic.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery +#![cfg(panic = "unwind")] use futures::future; use std::error::Error; @@ -12,7 +13,6 @@ mod support { } use support::panic::test_panic; -#[cfg(panic = "unwind")] #[test] fn pause_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -30,7 +30,6 @@ fn pause_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(panic = "unwind")] #[test] fn resume_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -47,7 +46,6 @@ fn resume_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(panic = "unwind")] #[test] fn interval_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -60,7 +58,6 @@ fn interval_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(panic = "unwind")] #[test] fn interval_at_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -73,7 +70,6 @@ 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 2750fc5c8..a14f7e22c 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -36,7 +36,7 @@ async fn pause_time_in_main_threads() { tokio::time::pause(); } -#[cfg(panic = "unwind")] +#[cfg_attr(panic = "abort", ignore)] #[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() {