Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less confusing message for failed test returning Result #97586

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions library/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ fn make_owned_test(test: &&TestDescAndFn) -> TestDescAndFn {
/// and checks for a `0` result.
pub fn assert_test_result<T: Termination>(result: T) {
let code = result.report().to_i32();
assert_eq!(
code, 0,
assert!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_eq also accepts an error message

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was assert_eq with error message. It results in confusing output, please see examples in initial comment or diff's comment

Copy link
Contributor

@ssomers ssomers Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assert_eq here doesn't help, because the message already reports the code value, if it needs to be reported at all. Instead, it harms as shown in the description, in #69517 and in #59263.

In fact the fix was already approved as #59263 but eventually landed in an outdated repository.

code == 0,
"the test returned a termination value with a non-zero status code ({}) \
which indicates a failure",
code
Expand Down