-
Notifications
You must be signed in to change notification settings - Fork 6
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
Check panics early when run in a loop #23
Comments
You are correct that this only works within the same scope. However, I also totally agree with the behaviour you want. I want it too ;) The biggest problem now is that we must panic to fail a test. The best thing we can do is delay the panic until a later point. So the Something like |
I'm not really familiar with the capabilities of macros in Rust, but the only real solution I can think of would probably have a macro like |
Yeah we can probably just add that to the standard library. :) The alternative is for assert2 to provide its own |
Right, that would be the best solution I think. Returning a boolean or other object that you can forget to use sounds like a potential footgun. Although multithreading and async code may make |
Yes, we need inheritable thread locals. Would be cool to have those.
Yeah, but those are usually 'forwarded' to the main thread by Alternatively, assert2 could have something like a |
I think Having |
You could have a version of check that returned the scope guard so then you could decide when to drop it? |
Hi, I found this library when looking for a way to run tests with multiple assertions that all evaluate and report errors before panicking at the end. From reading your docs, it appears that the
check!
macro in this library is intended to do that. However, it doesn't appear to be working for me when run in a loop (I assume it only works within a single scope?). Here's my use case:I'm writing a program designed to process a builtin config with many different "command" definitions, and for ease of use the tests for each command are embedded in the same config. I'd like my test to run and report on each "test" in the config, so one failing test doesn't stop the rest from being run.
I've deliberately tweaked the above config the ensure two different tests fail. However, when running the tests, only one assertion failed is reported before the test panics. See my test code and test output below. You can see the
check!
is run in a loop.I tried putting two
check!
calls back to back in the same scope, and that did work as expected; both reported failure before the panic. So, it appears multiplecheck!
calls are limited to running together only if they exist in the same scope.I assume this is by design and not a bug, but I'd love a feature in this repo that lets me check and report on multiple conditions dynamically within a loop regardless of scope.
The text was updated successfully, but these errors were encountered: