Skip to content

Commit 6411aef

Browse files
committed
improve diagnostics for tests with custom return values
fixes #52436
1 parent 9d6f4e5 commit 6411aef

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libtest/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,14 @@ pub fn test_main_static(tests: &[TestDescAndFn]) {
326326
/// test is considered a failure. By default, invokes `report()`
327327
/// and checks for a `0` result.
328328
pub fn assert_test_result<T: Termination>(result: T) {
329-
assert_eq!(result.report(), 0);
329+
let code = result.report();
330+
assert_eq!(
331+
code,
332+
0,
333+
"the test returned a termination value with a non-zero status code ({}) \
334+
which indicates a failure",
335+
code
336+
);
330337
}
331338

332339
#[derive(Copy, Clone, Debug)]

0 commit comments

Comments
 (0)