-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add tests for OutputFileHandler #84
Add tests for OutputFileHandler #84
Conversation
Signed-off-by: Stephen Brawner <[email protected]>
test/console_TEST.cc
Outdated
CONSOLE_BRIDGE_logDebug("Testing Log"); | ||
CONSOLE_BRIDGE_logInform("Testing Log"); | ||
CONSOLE_BRIDGE_logWarn("Testing Log"); | ||
CONSOLE_BRIDGE_logError("Testing Log"); |
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.
Other than coverage, this isn't a super helpful test as there are no ASSERT
/EXPECT
here. Most of the point of the OutputHandlerString
class is so we can capture these and test against them. So with that in mind, I'd suggest just reusing the OutputHandlerString
class here, and calling it at the various levels.
Alternatively, if you want to test the default handler for stdout, you can do something like #74.
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.
The test is just to add the default handler code path to the test file. I don't have a good solution to capturing stdout/stderr for testing purposes. I just ran into this issue with ros2/rcutils#258. It looks like it is currently not recommended to use testing::internal::CaptureStdout()
since it's in an internal namespace.
I've added expect_no_throw statements for now. I'm not yet convinced it's actually adding coverage. I'll remove the test if it doesn't actually affect coverage.
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 like this test adds a couple of lines and bumps coverage over 95% with setLogLevel
to debug.
8c9b652
to
58513f9
Compare
Codecov Report
@@ Coverage Diff @@
## master #84 +/- ##
===========================================
+ Coverage 65.00% 98.33% +33.33%
===========================================
Files 2 2
Lines 60 60
===========================================
+ Hits 39 59 +20
+ Misses 21 1 -20
Continue to review full report at Codecov.
|
58513f9
to
8f5f5ab
Compare
The |
Signed-off-by: Stephen Brawner <[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.
A few minor nits, but I'll approve anyway.
Signed-off-by: Stephen Brawner <[email protected]>
this looks good, but I was just tinkering with the test and re-arranged the order of the test cases in scpeters@3e5db76 and now one of them fails on my mac
do you have any thoughts? |
Signed-off-by: Stephen Brawner <[email protected]>
Addressed initialization issue. It looks like DOH is only initialized once in the whole test file. |
It looks like OutputFileHandler was the only feature that is not currently tested in this package. This adds a test for that, and also basic stdout/stderr smoke tests.
Signed-off-by: Stephen Brawner [email protected]