Skip to content

Mark some std tests as requiring panic = "unwind" #138294

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

Merged
merged 1 commit into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions library/std/src/thread/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn test_is_finished() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_join_panic() {
match thread::spawn(move || panic!()).join() {
result::Result::Err(_) => (),
Expand Down Expand Up @@ -210,6 +211,7 @@ fn test_simple_newsched_spawn() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_try_panic_message_string_literal() {
match thread::spawn(move || {
panic!("static string");
Expand All @@ -226,6 +228,7 @@ fn test_try_panic_message_string_literal() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_try_panic_any_message_owned_str() {
match thread::spawn(move || {
panic_any("owned string".to_string());
Expand All @@ -242,6 +245,7 @@ fn test_try_panic_any_message_owned_str() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_try_panic_any_message_any() {
match thread::spawn(move || {
panic_any(Box::new(413u16) as Box<dyn Any + Send>);
Expand All @@ -260,6 +264,7 @@ fn test_try_panic_any_message_any() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_try_panic_any_message_unit_struct() {
struct Juju;

Expand Down
10 changes: 10 additions & 0 deletions library/std/tests/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fn test_into_inner_drop() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_into_inner_poison() {
let m = new_poisoned_mutex(NonCopy(10));

Expand All @@ -135,6 +136,7 @@ fn test_get_cloned() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_get_cloned_poison() {
let m = new_poisoned_mutex(Cloneable(10));

Expand All @@ -152,6 +154,7 @@ fn test_get_mut() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_get_mut_poison() {
let mut m = new_poisoned_mutex(NonCopy(10));

Expand Down Expand Up @@ -179,6 +182,7 @@ fn test_set() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_set_poison() {
fn inner<T>(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T)
where
Expand Down Expand Up @@ -217,6 +221,7 @@ fn test_replace() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_replace_poison() {
fn inner<T>(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T)
where
Expand Down Expand Up @@ -261,6 +266,7 @@ fn test_mutex_arc_condvar() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_arc_condvar_poison() {
let packet = Packet(Arc::new((Mutex::new(1), Condvar::new())));
let packet2 = Packet(packet.0.clone());
Expand Down Expand Up @@ -290,6 +296,7 @@ fn test_arc_condvar_poison() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_mutex_arc_poison() {
let arc = Arc::new(Mutex::new(1));
assert!(!arc.is_poisoned());
Expand All @@ -304,6 +311,7 @@ fn test_mutex_arc_poison() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_mutex_arc_poison_mapped() {
let arc = Arc::new(Mutex::new(1));
assert!(!arc.is_poisoned());
Expand Down Expand Up @@ -335,6 +343,7 @@ fn test_mutex_arc_nested() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_mutex_arc_access_in_unwind() {
let arc = Arc::new(Mutex::new(1));
let arc2 = arc.clone();
Expand Down Expand Up @@ -381,6 +390,7 @@ fn test_mapping_mapped_guard() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn panic_while_mapping_unlocked_poison() {
let lock = Mutex::new(());

Expand Down
4 changes: 4 additions & 0 deletions library/std/tests/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fn stampede_once() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn poison_bad() {
static O: Once = Once::new();

Expand Down Expand Up @@ -80,6 +81,7 @@ fn poison_bad() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn wait_for_force_to_finish() {
static O: Once = Once::new();

Expand Down Expand Up @@ -137,6 +139,7 @@ fn wait() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn wait_on_poisoned() {
let once = Once::new();

Expand All @@ -145,6 +148,7 @@ fn wait_on_poisoned() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn wait_force_on_poisoned() {
let once = Once::new();

Expand Down
6 changes: 4 additions & 2 deletions library/std/tests/sync/once_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ fn get_or_try_init() {
let cell: OnceLock<String> = OnceLock::new();
assert!(cell.get().is_none());

let res = panic::catch_unwind(|| cell.get_or_try_init(|| -> Result<_, ()> { panic!() }));
assert!(res.is_err());
if cfg!(panic = "unwind") {
let res = panic::catch_unwind(|| cell.get_or_try_init(|| -> Result<_, ()> { panic!() }));
assert!(res.is_err());
}
assert!(cell.get().is_none());

assert_eq!(cell.get_or_try_init(|| Err(())), Err(()));
Expand Down
16 changes: 16 additions & 0 deletions library/std/tests/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fn frob() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_poison_wr() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -85,6 +86,7 @@ fn test_rw_arc_poison_wr() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_poison_mapped_w_r() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -98,6 +100,7 @@ fn test_rw_arc_poison_mapped_w_r() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_poison_ww() {
let arc = Arc::new(RwLock::new(1));
assert!(!arc.is_poisoned());
Expand All @@ -112,6 +115,7 @@ fn test_rw_arc_poison_ww() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_poison_mapped_w_w() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -126,6 +130,7 @@ fn test_rw_arc_poison_mapped_w_w() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_no_poison_rr() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -139,6 +144,7 @@ fn test_rw_arc_no_poison_rr() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_no_poison_mapped_r_r() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -153,6 +159,7 @@ fn test_rw_arc_no_poison_mapped_r_r() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_no_poison_rw() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand All @@ -166,6 +173,7 @@ fn test_rw_arc_no_poison_rw() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_no_poison_mapped_r_w() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand Down Expand Up @@ -218,6 +226,7 @@ fn test_rw_arc() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_rw_arc_access_in_unwind() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
Expand Down Expand Up @@ -316,6 +325,7 @@ fn test_into_inner_drop() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_into_inner_poison() {
let m = new_poisoned_rwlock(NonCopy(10));

Expand All @@ -333,6 +343,7 @@ fn test_get_cloned() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_get_cloned_poison() {
let m = new_poisoned_rwlock(Cloneable(10));

Expand All @@ -350,6 +361,7 @@ fn test_get_mut() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_get_mut_poison() {
let mut m = new_poisoned_rwlock(NonCopy(10));

Expand Down Expand Up @@ -377,6 +389,7 @@ fn test_set() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_set_poison() {
fn inner<T>(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T)
where
Expand Down Expand Up @@ -415,6 +428,7 @@ fn test_replace() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn test_replace_poison() {
fn inner<T>(mut init: impl FnMut() -> T, mut value: impl FnMut() -> T)
where
Expand Down Expand Up @@ -482,6 +496,7 @@ fn test_mapping_mapped_guard() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn panic_while_mapping_read_unlocked_no_poison() {
let lock = RwLock::new(());

Expand Down Expand Up @@ -551,6 +566,7 @@ fn panic_while_mapping_read_unlocked_no_poison() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn panic_while_mapping_write_unlocked_poison() {
let lock = RwLock::new(());

Expand Down
Loading