Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: gate unwind tests and add ci step for tesing with panic=abort #6283

Merged
merged 7 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust_stable }}
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust_nightly }}
maminrayej marked this conversation as resolved.
Show resolved Hide resolved
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
Expand All @@ -148,6 +152,11 @@ jobs:
cargo nextest run --workspace --all-features
cargo test --doc --workspace --all-features

- name: test all --all-features panic=abort
run: |
set -euxo pipefail
RUSTFLAGS="-C panic=abort -Zpanic-abort-tests" cargo +nightly nextest run --workspace --exclude tokio-macros --all-features --tests

test-integration-tests-per-feature:
needs: basics
name: Run integration tests for each feature
Expand Down
1 change: 1 addition & 0 deletions tokio-stream/tests/stream_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fn test_panic<Func: FnOnce() + panic::UnwindSafe>(func: Func) -> Option<String>
}

#[test]
#[cfg(panic = "unwind")]
fn stream_chunks_timeout_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let iter = vec![1, 2, 3].into_iter();
Expand Down
12 changes: 10 additions & 2 deletions tokio-util/tests/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn test_panic<Func: FnOnce() + panic::UnwindSafe>(func: Func) -> Option<String>
}

#[test]
#[cfg(panic = "unwind")]
fn sync_bridge_new_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = SyncIoBridge::new(tokio::io::empty());
Expand All @@ -61,6 +62,7 @@ fn sync_bridge_new_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn poll_sender_send_item_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let (send, _) = channel::<u32>(3);
Expand All @@ -76,7 +78,7 @@ fn poll_sender_send_item_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]

#[cfg(panic = "unwind")]
fn local_pool_handle_new_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let _ = LocalPoolHandle::new(0);
Expand All @@ -89,7 +91,7 @@ fn local_pool_handle_new_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]

#[cfg(panic = "unwind")]
fn local_pool_handle_spawn_pinned_by_idx_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -106,6 +108,7 @@ fn local_pool_handle_spawn_pinned_by_idx_panic_caller() -> Result<(), Box<dyn Er
Ok(())
}
#[test]
#[cfg(panic = "unwind")]
fn delay_queue_insert_at_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -127,6 +130,7 @@ fn delay_queue_insert_at_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn delay_queue_insert_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -144,6 +148,7 @@ fn delay_queue_insert_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn delay_queue_remove_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -163,6 +168,7 @@ fn delay_queue_remove_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn delay_queue_reset_at_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -184,6 +190,7 @@ fn delay_queue_reset_at_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn delay_queue_reset_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand All @@ -202,6 +209,7 @@ fn delay_queue_reset_panic_caller() -> Result<(), Box<dyn Error>> {
}

#[test]
#[cfg(panic = "unwind")]
fn delay_queue_reserve_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = basic();
Expand Down
2 changes: 2 additions & 0 deletions tokio-util/tests/spawn_pinned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions tokio-util/tests/time_delay_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions tokio/tests/io_panic.rs
maminrayej marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fn unsplit_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn async_fd_new_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::io::unix::AsyncFd;
use tokio::runtime::Builder;
Expand All @@ -159,6 +160,7 @@ fn async_fd_new_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn async_fd_with_interest_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::io::unix::AsyncFd;
use tokio::io::Interest;
Expand Down
4 changes: 4 additions & 0 deletions tokio/tests/net_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn tcp_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn unix_listener_bind_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::net::UnixListener;

Expand All @@ -96,6 +97,7 @@ fn unix_listener_bind_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn unix_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::net::UnixListener;

Expand All @@ -118,6 +120,7 @@ fn unix_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn unix_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
use tokio::net::UnixStream;

Expand All @@ -141,6 +144,7 @@ fn unix_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {

#[test]
#[cfg(unix)]
#[cfg(panic = "unwind")]
fn unix_datagram_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
use std::os::unix::net::UnixDatagram as StdUDS;
use tokio::net::UnixDatagram;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/process_issue_2174.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use tokio::time;
use tokio_test::assert_err;

#[tokio::test]
#[cfg(panic = "unwind")]
async fn issue_2174() {
let mut child = Command::new("sleep")
.arg("2")
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod support {
use support::panic::test_panic;

#[test]
#[cfg(panic = "unwind")]
fn signal_panic_caller() -> Result<(), Box<dyn Error>> {
let panic_location_file = test_panic(|| {
let rt = Builder::new_current_thread().build().unwrap();
Expand Down
Loading