]> git.lizzy.rs Git - rust.git/blob - src/test/ui/test-panic-abort.rs
Auto merge of #67290 - jonas-schievink:leak-audit, r=KodrAus
[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
11 #![cfg(test)]
12
13 use std::io::Write;
14 use std::env;
15
16 #[test]
17 fn it_works() {
18     assert_eq!(1 + 1, 2);
19 }
20
21 #[test]
22 #[should_panic]
23 fn it_panics() {
24     assert_eq!(1 + 1, 4);
25 }
26
27 #[test]
28 fn it_fails() {
29     println!("hello, world");
30     writeln!(std::io::stdout(), "testing123").unwrap();
31     writeln!(std::io::stderr(), "testing321").unwrap();
32     assert_eq!(1 + 1, 5);
33 }
34
35 #[test]
36 fn it_exits() {
37     std::process::exit(123);
38 }
39
40 #[test]
41 fn no_residual_environment() {
42     for (key, _) in env::vars() {
43         // Look for keys like __RUST_TEST_INVOKE.
44         if key.contains("TEST_INVOKE") {
45             panic!("shouldn't have '{}' in environment", key);
46         }
47     }
48 }