-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improvements to the #[should_panic] feature #37749
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I restarted the test which failed (for some reasons...). |
758bc43
to
5f80f02
Compare
You should also add tests to check
|
Aren't the tests that are already present covering this? |
@keeperofdakeys yes, but this only tests part of the code. The parts that you added aren't tested (extracting the string from the expected attribute). It would be nicer to test all of it. |
5f80f02
to
2114baa
Compare
I've updated the |
Hmm, I suppose this is a back-compat breaking change because people who used the bad forms previously will get an error when there was none previously. Annoyingly, Crater will not pick up such errors. I think therefore that this needs to be a warning, rather than an error for one cycle. |
LGTM, otherwise |
2114baa
to
d1e3c11
Compare
Since it seems you can't insert lints in libsyntax, I've changed the errors into warnings, and added notes about future changes. |
@keeperofdakeys that's still not fullfilling the complete potential of the test, It still doesn't test whether the thing you specify in |
@est31 I don't understand the exact point you're trying to make, could you elaborate? |
This looks good, except that I'm not sure about the new output:
I don't think there's any other such inline output about what happened in the test for any other sort of test, and I'm reluctant to start the precedent here. Usually this type of information is printed to stderr, captured by the test runner, and printed as part of the final summary list of failures, and I'd prefer if this information could be presented similarly. |
@keeperofdakeys the unit tests you linked to use internal testing functions, and don't use the |
1eee8e3
to
72ee3e6
Compare
I've updated the output to:
@est31 Ah, thanks for clarifying. Since writing a unit test for |
@bors: r+ |
📌 Commit 72ee3e6 has been approved by |
⌛ Testing commit 72ee3e6 with merge 0a1b0f4... |
💔 Test failed - auto-linux-64-opt |
72ee3e6
to
fb5ccf8
Compare
Whoops, looks like I accidentally made a heisentest. I've split it out into two files now. |
Strange, travis-ci failed before compilation. |
@bors: r+ |
📌 Commit fb5ccf8 has been approved by |
Improvements to the #[should_panic] feature Add more error checking for the `#[should_panic]` attribute, and print the expected panic string when it does not match. Fixes #29000 Eg: ```running 3 tests test test2 ... ok test test1 ... FAILED : Panic did not include expected string 'foo' test test3 ... FAILED failures: ---- test1 stdout ---- thread 'test1' panicked at 'bar', test.rs:7 note: Run with `RUST_BACKTRACE=1` for a backtrace. ---- test3 stdout ---- thread 'test3' panicked at 'bar', test.rs:18 ```
Add more error checking for the
#[should_panic]
attribute, and print the expected panic string when it does not match.Fixes #29000
Eg: