about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/test-panic-abort.rs36
-rw-r--r--src/test/ui/test-panic-abort.run.stdout29
2 files changed, 65 insertions, 0 deletions
diff --git a/src/test/ui/test-panic-abort.rs b/src/test/ui/test-panic-abort.rs
new file mode 100644
index 00000000000..b77bb78b4b1
--- /dev/null
+++ b/src/test/ui/test-panic-abort.rs
@@ -0,0 +1,36 @@
+// no-prefer-dynamic
+// compile-flags: --test -Cpanic=abort
+// run-flags: --test-threads=1
+// run-fail
+// check-run-results
+
+// ignore-wasm no panic or subprocess support
+// ignore-emscripten no panic or subprocess support
+
+#![cfg(test)]
+
+use std::io::Write;
+
+#[test]
+fn it_works() {
+    assert_eq!(1 + 1, 2);
+}
+
+#[test]
+#[should_panic]
+fn it_panics() {
+    assert_eq!(1 + 1, 4);
+}
+
+#[test]
+fn it_fails() {
+    println!("hello, world");
+    writeln!(std::io::stdout(), "testing123").unwrap();
+    writeln!(std::io::stderr(), "testing321").unwrap();
+    assert_eq!(1 + 1, 5);
+}
+
+#[test]
+fn it_exits() {
+    std::process::exit(123);
+}
diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout
new file mode 100644
index 00000000000..32c96b4f849
--- /dev/null
+++ b/src/test/ui/test-panic-abort.run.stdout
@@ -0,0 +1,29 @@
+
+running 4 tests
+test it_exits ... FAILED
+test it_fails ... FAILED
+test it_panics ... ok
+test it_works ... ok
+
+failures:
+
+---- it_exits stdout ----
+---- it_exits stderr ----
+note: got unexpected return code 123
+---- it_fails stdout ----
+hello, world
+testing123
+---- it_fails stderr ----
+testing321
+thread 'main' panicked at 'assertion failed: `(left == right)`
+  left: `2`,
+ right: `5`', $DIR/test-panic-abort.rs:30:5
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
+
+
+failures:
+    it_exits
+    it_fails
+
+test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
+