File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ // no-prefer-dynamic
2+ // compile-flags: --test -Cpanic=abort
3+ // run-flags: --test-threads=1
4+ // run-fail
5+ // check-run-results
6+
7+ // ignore-wasm no panic or subprocess support
8+ // ignore-emscripten no panic or subprocess support
9+
10+ #![ cfg( test) ]
11+
12+ use std:: io:: Write ;
13+
14+ #[ test]
15+ fn it_works ( ) {
16+ assert_eq ! ( 1 + 1 , 2 ) ;
17+ }
18+
19+ #[ test]
20+ #[ should_panic]
21+ fn it_panics ( ) {
22+ assert_eq ! ( 1 + 1 , 4 ) ;
23+ }
24+
25+ #[ test]
26+ fn it_fails ( ) {
27+ println ! ( "hello, world" ) ;
28+ writeln ! ( std:: io:: stdout( ) , "testing123" ) . unwrap ( ) ;
29+ writeln ! ( std:: io:: stderr( ) , "testing321" ) . unwrap ( ) ;
30+ assert_eq ! ( 1 + 1 , 5 ) ;
31+ }
32+
33+ #[ test]
34+ fn it_exits ( ) {
35+ std:: process:: exit ( 123 ) ;
36+ }
Original file line number Diff line number Diff line change 1+
2+ running 4 tests
3+ test it_exits ... FAILED
4+ test it_fails ... FAILED
5+ test it_panics ... ok
6+ test it_works ... ok
7+
8+ failures:
9+
10+ ---- it_exits stdout ----
11+ ---- it_exits stderr ----
12+ note: got unexpected return code 123
13+ ---- it_fails stdout ----
14+ hello, world
15+ testing123
16+ ---- it_fails stderr ----
17+ testing321
18+ thread 'main' panicked at 'assertion failed: `(left == right)`
19+ left: `2`,
20+ right: `5`', $DIR/test-panic-abort.rs:30:5
21+ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
22+
23+
24+ failures:
25+ it_exits
26+ it_fails
27+
28+ test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
29+
You can’t perform that action at this time.
0 commit comments