Skip to content

Commit 3313bf6

Browse files
committed
Skip leak test on targets without panic=unwind
1 parent 591584e commit 3313bf6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/tests/array.rs

+8
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,14 @@ fn iterator_drops() {
242242
assert_eq!(i.get(), 5);
243243
}
244244

245+
// This test does not work on targets without panic=unwind support.
246+
// To work around this problem, test is marked is should_panic, so it will
247+
// be automagically skipped on unsuitable targets, such as
248+
// wasm32-unknown-unkown.
249+
//
250+
// It means that we use panic for indicating success.
245251
#[test]
252+
#[should_panic(expected = "test succeeded")]
246253
fn array_default_impl_avoids_leaks_on_panic() {
247254
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
248255
static COUNTER: AtomicUsize = AtomicUsize::new(0);
@@ -274,6 +281,7 @@ fn array_default_impl_avoids_leaks_on_panic() {
274281
assert_eq!(*panic_msg, "bomb limit exceeded");
275282
// check that all bombs are successfully dropped
276283
assert_eq!(COUNTER.load(Relaxed), 0);
284+
panic!("test succeeded")
277285
}
278286

279287
#[test]

0 commit comments

Comments
 (0)