Print failure message on all tests that should panic, but don't
This already happens with should_panic tests without an expected message. This commit fixes should_panic tests with an expected message to have the same behavior.
This commit is contained in:
parent
7cf205610e
commit
b43aa960d0
|
@ -63,7 +63,7 @@ pub fn calc_result<'a>(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(&ShouldPanic::Yes, Ok(())) => {
|
(&ShouldPanic::Yes, Ok(())) | (&ShouldPanic::YesWithMessage(_), Ok(())) => {
|
||||||
TestResult::TrFailedMsg("test did not panic as expected".to_string())
|
TestResult::TrFailedMsg("test did not panic as expected".to_string())
|
||||||
}
|
}
|
||||||
_ if desc.allow_fail => TestResult::TrAllowedFail,
|
_ if desc.allow_fail => TestResult::TrAllowedFail,
|
||||||
|
|
|
@ -228,21 +228,30 @@ fn test_should_panic_non_string_message_type() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(target_os = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
fn test_should_panic_but_succeeds() {
|
fn test_should_panic_but_succeeds() {
|
||||||
fn f() {}
|
let should_panic_variants = [ShouldPanic::Yes, ShouldPanic::YesWithMessage("error message")];
|
||||||
let desc = TestDescAndFn {
|
|
||||||
desc: TestDesc {
|
for &should_panic in should_panic_variants.iter() {
|
||||||
name: StaticTestName("whatever"),
|
fn f() {}
|
||||||
ignore: false,
|
let desc = TestDescAndFn {
|
||||||
should_panic: ShouldPanic::Yes,
|
desc: TestDesc {
|
||||||
allow_fail: false,
|
name: StaticTestName("whatever"),
|
||||||
test_type: TestType::Unknown,
|
ignore: false,
|
||||||
},
|
should_panic,
|
||||||
testfn: DynTestFn(Box::new(f)),
|
allow_fail: false,
|
||||||
};
|
test_type: TestType::Unknown,
|
||||||
let (tx, rx) = channel();
|
},
|
||||||
run_test(&TestOpts::new(), false, desc, RunStrategy::InProcess, tx, Concurrent::No);
|
testfn: DynTestFn(Box::new(f)),
|
||||||
let result = rx.recv().unwrap().result;
|
};
|
||||||
assert_eq!(result, TrFailedMsg("test did not panic as expected".to_string()));
|
let (tx, rx) = channel();
|
||||||
|
run_test(&TestOpts::new(), false, desc, RunStrategy::InProcess, tx, Concurrent::No);
|
||||||
|
let result = rx.recv().unwrap().result;
|
||||||
|
assert_eq!(
|
||||||
|
result,
|
||||||
|
TrFailedMsg("test did not panic as expected".to_string()),
|
||||||
|
"should_panic == {:?}",
|
||||||
|
should_panic
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_time_test_template(report_time: bool) -> Option<TestExecTime> {
|
fn report_time_test_template(report_time: bool) -> Option<TestExecTime> {
|
||||||
|
|
Loading…
Reference in a new issue