From 6411aef60952bc0cbad8095d689a6c532f2f31d1 Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Tue, 17 Jul 2018 20:59:48 +1000 Subject: [PATCH] improve diagnostics for tests with custom return values fixes #52436 --- src/libtest/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 6b547dff912..76e042b063f 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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(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)]