diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-08-15 19:20:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-15 19:20:19 +0200 |
| commit | d8815cfe7daf571617ddd0eeecdf8cb9041b893a (patch) | |
| tree | e08138b608ced9233c17eec512166b31a9e2e6de /src/libtest/lib.rs | |
| parent | 0f4b4987cd6dea5406dec0634770839fb31ce72c (diff) | |
| parent | 6411aef60952bc0cbad8095d689a6c532f2f31d1 (diff) | |
| download | rust-d8815cfe7daf571617ddd0eeecdf8cb9041b893a.tar.gz rust-d8815cfe7daf571617ddd0eeecdf8cb9041b893a.zip | |
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!
Diffstat (limited to 'src/libtest/lib.rs')
| -rw-r--r-- | src/libtest/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 30094223d08..060ea1ea9b1 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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)] |
