-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support assertion handler testing when tests compiled with -fno-exceptions #1843
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
Conversation
…tions Signed-off-by: Isaev, Ilya <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
test/common/utils_assert.h
Outdated
bool okay = false; \ | ||
if (setjmp(utils::g_assertion_jmp_buf)) { \ | ||
okay = true; \ | ||
message = utils::g_assertion_failure->message; \ | ||
} else { \ | ||
x; \ | ||
} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to swap if and else branches to better match the original test?
I also thought about keeping only this implementation as the only test:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going one step further, I had an idea to merge two implementations as several lines are identical. However, it might negatively impact the overall readability. Although the macro will be smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the exception implementation is better overall and should be used when possible.
I had an idea to merge two implementations as several lines are identical. However, it might negatively impact the overall readability. Although the macro will be smaller.
This macro is relatively small, so small code duplication is OK here.
I swapped branches.
Signed-off-by: Isaev, Ilya <[email protected]>
Description
Use
setjmp/std::longjmp
for custom assertion handler in testing instead of exceptions for test builds with-fno-exception
flag.Fixes # - issue number(s) if exists
Type of change
Choose one or multiple, leave empty if none of the other choices apply
Add a respective label(s) to PR if you have permissions
Tests
Documentation
Breaks backward compatibility
Notify the following users
List users with
@
to send notificationsOther information