Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

try to avoid multiline panics #14

Closed
colin-kiegel opened this issue Mar 20, 2017 · 3 comments
Closed

try to avoid multiline panics #14

colin-kiegel opened this issue Mar 20, 2017 · 3 comments

Comments

@colin-kiegel
Copy link
Collaborator

colin-kiegel commented Mar 20, 2017

I started poking around and found this panic message

        thread 'tests::test' panicked at 'Assert CLI failure:
Expected output to contain
41
but could not find it in
42
', /some/file

This reminds me that my atom IDE currently fails to parse multi-line panics - I just filed this issue yesterday. ^^ AtomBuild/atom-build-cargo#85

When I compare it with the output of assert_eq!(42, 41);

... 'assertion failed: `(left == right)` (left: `42`, right: `41`)' ...

How about something similar to what we already know from std:

... 'CLI assertion failed: `(Output expected to contain `41`)` (observed: `42`)' ...
@killercup
Copy link
Collaborator

I only did that because the print_exactly panic is a full, colorful diff anyway… and instead of 42 and 41 the values could well be Lorem ipsum dolor and the full help message…

@colin-kiegel
Copy link
Collaborator Author

Ok, interesting. Would it be an option to print to stderr before panicking?

stderr output could be multi-line, and the panic only a one-line summary? That might lead to garbled output, when multiple tests run concurrently - I'm not really sure. I'm just thinking out loud about alternatives. :-)

If you ask me, at least the case above looks nicer in one line.

@colin-kiegel
Copy link
Collaborator Author

I will submit a suggestion in a PR. :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants