-
Notifications
You must be signed in to change notification settings - Fork 273
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
~LogCapture() should be noexcept (false) ? #343
Comments
Hi, g3log uses Line 110 in a6788f8
setFatalExitHandler(...)
You can see test_io.cpp which does this frequently using RestoreFileLogger::RestoreFileLogger(...) which sets this. g3log/test_unit/testing_helpers.cpp Line 117 in a6788f8
|
The |
In either case it will be called from destructor, so
will also lead to abort. So I don't think those comments in source code are correct:
|
Check the test_io.cpp . I'm running many, many tests with FATAL |
You are correct that the code comment should be updated. |
Sorry, I still don't get it, probably I've missing something. I've checked test_io.cpp and I don't see EXPECT_THROW tests there, instead mock installs fatal handler that will push message to logger but will allow code with broken invariant to continue. |
I think throwing exception from CHECK, as comments suggest is a good idea for unit testing. |
As it’s currently implemented that’s not how it’s done. I’ve provided the pattern for verifying failed CHECK. If that doesn’t work for your requirements then please provide a PR that targets your concerns and I will take it under evaluation |
In a g3log.hpp I read:
So my understanding is that for unit testing I can install setFatalPreLoggingHook that will throw, so I can unit-test contracts with EXPECT_THROW(). However LogCapture() destructor is noexcept (by default), so any attempt to throw from CHECK() will lead to std::terminate.
The text was updated successfully, but these errors were encountered: