]> git.lizzy.rs Git - rust.git/commitdiff
Skip leak test on targets without panic=unwind
authorMikail Bagishov <bagishov.mikail@yandex.ru>
Thu, 28 May 2020 17:45:21 +0000 (20:45 +0300)
committerMikail Bagishov <bagishov.mikail@yandex.ru>
Thu, 28 May 2020 17:45:21 +0000 (20:45 +0300)
src/libcore/tests/array.rs

index 41855a9a8cbab27ad50ce41077f5fab856830f7a..4bc44e98fc802a7efee5106bac8409c3b0cfa9e7 100644 (file)
@@ -242,7 +242,14 @@ fn drop(&mut self) {
     assert_eq!(i.get(), 5);
 }
 
+// This test does not work on targets without panic=unwind support.
+// To work around this problem, test is marked is should_panic, so it will
+// be automagically skipped on unsuitable targets, such as
+// wasm32-unknown-unkown.
+//
+// It means that we use panic for indicating success.
 #[test]
+#[should_panic(expected = "test succeeded")]
 fn array_default_impl_avoids_leaks_on_panic() {
     use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
     static COUNTER: AtomicUsize = AtomicUsize::new(0);
@@ -274,6 +281,7 @@ fn drop(&mut self) {
     assert_eq!(*panic_msg, "bomb limit exceeded");
     // check that all bombs are successfully dropped
     assert_eq!(COUNTER.load(Relaxed), 0);
+    panic!("test succeeded")
 }
 
 #[test]