Skip to content
This repository was archived by the owner on Aug 12, 2021. It is now read-only.

Improve output when #[test] returns an Err(_) value #9

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,14 @@ pub fn test_main_static(tests: &[&TestDescAndFn]) {
/// and checks for a `0` result.
pub fn assert_test_result<T: Termination>(result: T) {
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
);
if code != 0 {
panic!(
"the test returned a termination value with a non-zero status code ({}) \
which indicates a failure (this most likely means your test returned \
an `Err(_)` value)",
code,
);
}
}

#[derive(Copy, Clone, Debug)]
Expand Down