]> git.lizzy.rs Git - rust.git/blob - src/test/ui/test-panic-abort.rs
Auto merge of #75276 - JohnTitor:rollup-rz4hs0w, r=JohnTitor
[rust.git] / src / test / ui / test-panic-abort.rs
1 // no-prefer-dynamic
2 // compile-flags: --test -Cpanic=abort -Zpanic_abort_tests
3 // run-flags: --test-threads=1
4 // run-fail
5 // check-run-results
6 // exec-env:RUST_BACKTRACE=0
7
8 // ignore-wasm no panic or subprocess support
9 // ignore-emscripten no panic or subprocess support
10 // ignore-sgx no subprocess support
11
12 #![cfg(test)]
13
14 use std::io::Write;
15 use std::env;
16
17 #[test]
18 fn it_works() {
19     assert_eq!(1 + 1, 2);
20 }
21
22 #[test]
23 #[should_panic]
24 fn it_panics() {
25     assert_eq!(1 + 1, 4);
26 }
27
28 #[test]
29 fn it_fails() {
30     println!("hello, world");
31     writeln!(std::io::stdout(), "testing123").unwrap();
32     writeln!(std::io::stderr(), "testing321").unwrap();
33     assert_eq!(1 + 1, 5);
34 }
35
36 #[test]
37 fn it_exits() {
38     std::process::exit(123);
39 }
40
41 #[test]
42 fn no_residual_environment() {
43     for (key, _) in env::vars() {
44         // Look for keys like __RUST_TEST_INVOKE.
45         if key.contains("TEST_INVOKE") {
46             panic!("shouldn't have '{}' in environment", key);
47         }
48     }
49 }