-
Notifications
You must be signed in to change notification settings - Fork 52
RFC: rework assert_return() macro #375
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
base: master
Are you sure you want to change the base?
Conversation
The current assert_return() macro has a few short comings: - the name implies assert() - all users unnecessarily provide EXIT_FAILURE - the users cannot provide a message - "Failed assertion:" isn't great Tweak it up and in the process bump it to ALL_CAPS, to better indicate that it's a macro and not a function. Preserve the original, since we're converting one test at a time - starting with test-hash. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Migrate to the new macro. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Swap the manual checks for the new OK() macro. In the process, we remove the cleanup in the error path. Many other tests don't bother, plus in the places that do try they don't always get it right/fully. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
I think not needing to provide the same EXIT_FAILURE and being able to provide a message is good. The rename I think is not really needed. What's the problem with the term assert? IMO it's clearer than "ok". igt for example uses a bunch of igt_assert_*. ok() IMO is odd, but it maybe because I've never seen it used like this. Rust also has both Ok() and assert!(), which I think will add to the confusion.
I think a bulk one. If the message is optional, then the first patch is automated. Additional patches may follow later (maybe per compile unit) to add some good messages. |
There is nothing wrong with the term in itself. The snafu happens due to Other naming options:
Don't have a strong preference though.
Awesome, will do.
Do the example commits reach that bar, or shall I just drop them? |
From the commit introducing it:
... and the follow-up commit:
Before going forward and porting more tests, would be great to hear if the direction is right.
If* it is, a couple of questions: