-
Notifications
You must be signed in to change notification settings - Fork 64
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
Migrate test suite to GoogleTest framework #119
Migrate test suite to GoogleTest framework #119
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
==========================================
- Coverage 95.64% 95.59% -0.05%
==========================================
Files 58 58
Lines 3860 3794 -66
==========================================
- Hits 3692 3627 -65
+ Misses 168 167 -1 ☔ View full report in Codecov by Sentry. |
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.
Thanks for the PR! The changes look good overall, I just had a couple of notes.
- For the RTNeural header, I think using
#include <RTNeural/RTNeural.h>
in both the tests and client code is the way to go. - I think there's some kind of linker error happening with
gmock
on MSVC. I think this can be fixed by adding this to our test targets:
set_property(TARGET foo PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
macro(rtneural_setup_testing) | ||
include(CTest) | ||
enable_testing() | ||
add_custom_target(rtneural_test COMMAND ctest -C ${Configuration} --output-on-failure) |
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.
Nice!
option(RTNEURAL_TEST_REPORTS "Output test reports to XML files" OFF) | ||
|
||
macro(rtneural_setup_testing) | ||
include(CTest) |
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 was under the impression that CTest
has to be included from the "top level" CMake script. But maybe this is okay because it's in a macro
? (I've never used CMake macro's before)
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 believe you're correct on both counts :)
A macro
in CMake is somewhat analogous to a C preprocessor macro - after the arguments are substituted into the body, it's as if the implementation of the macro is just copy/pasted into the call site. This particular macro has no arguments, so it's pretty much just a straight copy/paste of the macro body! The result is as you suspect - CTest is indeed included at the top level CMake script here 👍
1. unit tests, and | ||
2. functional tests. |
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.
This is great! I wonder if it might make sense to further split up the function tests into "layer" tests and "model" tests... at the moment we only have one model test, but I'm hoping to add more. Anyway, that's a change we can make later if we want to.
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.
Glad you like it! On splitting the functional tests into tests for layers vs models, I'm not sure. I'd be happy to jump on a call to chat about it with you at some point, if you like! I would consider whether the layer tests are simple enough to be written as unit tests - they're usually simpler, easier to reason about, and less brittle. But every project has different needs and challenges, so there's no one-size-fits-all :)
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.
Yeah, that's a good point. I'd like to do a bit of hacking myself just to get a sense of what might work, but yeah, no rush or anything, just putting some thoughts out there.
RTNeural/CMakeLists.txt
Outdated
.. | ||
./ |
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 I would prefer to leave the include path as #include <RTNeural/RTNeural.h>
, just to avoid having a breaking change for end-users, and then we could update the tests to use that include path also?
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.
For sure - sounds great. Totally agree on avoiding a breaking change. I'll update the tests and revert the include path!
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.
This one's done, and I've updated the PR description to match!
No problem - thanks for the review!
|
Awesome, thanks for the update! Yeah, trying the CMake option provided by GoogleTest sounds good. I think there's also a different include path thing happening in some of the examples, but otherwise we should be good to go :) |
Awesome, I'm happy to merge whenever you're ready, the only last thing would be to add yourself to the contributor's list if you'd like to. |
Nice one, thanks for the excellent review @jatinchowdhury18! I've updated the contributors list now and I'm ready for it to be merged too, assuming the CI passes 😁 |
This PR does the following:
rtneural_test_unit
andrtneural_test_functional
Activation
layerstests
folder, explaining how to build and run the tests (or a subset of them!)#include <RTNeural/RTNeural.h>
, to match the intended client code inclusion pattern