Rollup merge of #52453 - srijs:fix-52436, r=TimNN
improve diagnostics for tests with custom return values This is an attempt at getting the ball rolling to improve the diagnostics for test functions that return custom `impl Termination` values (see #52436). An alternative could be to use `eprintln!`, but including this in the panic message felt nicely consistent with how failing test assertions would be reported. Let me know what you think!
This commit is contained in:
commit
d8815cfe7d
@ -324,7 +324,14 @@ pub fn test_main_static(tests: &[TestDescAndFn]) {
|
||||
/// test is considered a failure. By default, invokes `report()`
|
||||
/// and checks for a `0` result.
|
||||
pub fn assert_test_result<T: Termination>(result: T) {
|
||||
assert_eq!(result.report(), 0);
|
||||
let code = result.report();
|
||||
assert_eq!(
|
||||
code,
|
||||
0,
|
||||
"the test returned a termination value with a non-zero status code ({}) \
|
||||
which indicates a failure",
|
||||
code
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user