-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Better error messages for #[should_panic] tests with expected strings #66304
Comments
Agree with having them vertically aligned. I think we do want line endings to create a new line though for multi-line readability. Maybe we should say something like this:
(The first difference at char line we might also want to add to assert_eq also?) |
The
to make that easier to spot. I think the escaping is essential, take for instance this test which has no newlines, but contains shell control characters to move the cursor:
On many shells, this will produce this output:
which makes it very hard for a user to figure out what's going on (let's assume the Maybe a more important reason is that escaping would be consistent with the behavior of
outputs:
The escaping avoids surprises which could occur depending on the user`s environment. |
Ok I'm sold. Do you want to fork rust-lang/rust and submit this as a PR? (If you don't want to I can do the legwork). |
Thanks for the offer, I'll try to write a PR and will add you as a reviewer once I have a first version ready. |
When running this test (playground):
the output is
which makes it hard to spot the difference in whitespace characters.
Would it be possible to change this to e.g.:
This would improve the usability when running into these kinds of test failures and also make it more consistent with
assert_eq
which outputs both the left and the right value too.The text was updated successfully, but these errors were encountered: