Skip to content

Commit

Permalink
Rollup merge of rust-lang#64745 - kennethbgoodin:should-panic-msg, r=…
Browse files Browse the repository at this point in the history
…varkor

Include message on tests that should panic but do not

As per issue rust-lang#60790 includes a message for tests marked `#[should_panic]` that do not panic as expected.

Fixes rust-lang#60790.
  • Loading branch information
Centril committed Sep 27, 2019
2 parents daa632b + 821ff46 commit 9c1b008
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ fn calc_result(desc: &TestDesc, task_result: Result<(), Box<dyn Any + Send>>) ->
}
}
}
(&ShouldPanic::Yes, Ok(())) => TrFailedMsg("test did not panic as expected".to_string()),
_ if desc.allow_fail => TrAllowedFail,
_ => TrFailed,
}
Expand Down
4 changes: 2 additions & 2 deletions src/libtest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;

use crate::test::{
filter_tests, parse_opts, run_test, DynTestFn, DynTestName, MetricMap, RunIgnored,
ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts, TrFailed, TrFailedMsg,
ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts, TrFailedMsg,
TrIgnored, TrOk,
};
use std::sync::mpsc::channel;
Expand Down Expand Up @@ -167,7 +167,7 @@ fn test_should_panic_but_succeeds() {
let (tx, rx) = channel();
run_test(&TestOpts::new(), false, desc, tx, Concurrent::No);
let (_, res, _, _) = rx.recv().unwrap();
assert!(res == TrFailed);
assert!(res == TrFailedMsg("test did not panic as expected".to_string()));
}

fn report_time_test_template(report_time: bool) -> Option<TestExecTime> {
Expand Down

0 comments on commit 9c1b008

Please sign in to comment.