Skip to content

Commit

Permalink
improve diagnostics for tests with custom return values
Browse files Browse the repository at this point in the history
fixes #52436
  • Loading branch information
srijs committed Aug 11, 2018
1 parent 9d6f4e5 commit 6411aef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,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)]
Expand Down

0 comments on commit 6411aef

Please sign in to comment.