-
Notifications
You must be signed in to change notification settings - Fork 198
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
[cache_unittest] Add direct implementation testing on ordering, pruning #678
[cache_unittest] Add direct implementation testing on ordering, pruning #678
Conversation
2656381
to
69370a8
Compare
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! I love the fact that we are adding tests first, this is super helpful.
About the implementation; I'm not a huge fan of adding in a TestFriend
class. While it is in the impl
namespace, it still can create confusion for downstream consumers since it is in the public header. I'd rather split out the cache into a separate class that we can then add unit tests for. While that is also visible in the public headers, it makes sense as a part of the implementation, and not just as a test fixture.
Gotcha. Is there a way to very explicitly denote a header file as internal? (i.e., it should not be considered as any part of stable API, and thus can be changed at a whim?) Perhaps placing it in |
Also, I can't tell what happened with CI; is this failure expected / unrelated to this PR?
|
Unrelated, it happens every once in a while in the infrastructure. When you push next it should hopefully ( 🤞 ) work. |
We could do that. But because of our ABI guarantees, it won't matter much anyway; we wouldn't be able to change the embedded data structure anyway. We could do a PIMPL thing here, but that has its own downsides. At this point I'm just happy enough leaving it in the public headers. |
Gotcha, so changing the underlying class, even if using same exact content / ordering, might affect ABI? This is a bit more than I'd prefer to bite off, at least for what could be a minimal, targeted performance improvement. Suggested options: I prefer (b), because I would like the minimum-effort / quickest solution that is a strict improvement. Can I ask your opinions? |
In general, my opinion is that we should always do what is best on In this specific case, I just really dislike having test fixtures in the public headers. As a downstream consumer of the header, it has no meaning, and it is testing/implementation "leaking" through the public headers. Instead, given that what we are trying to get access to is the "full" linked list to run tests, we could:
Of the two, I kind of prefer making One thing to note is that we probably will not be able to backport a change from private -> protected into Humble. However, I think it is less important that we backport the tests there, and instead it will be more important that we just backport the eventual performance fixes (which shouldn't require an ABI break). |
Gotcha, those are all fair points, and thanks!
I like making storage protected API as a minimum impact change, but I don't think it's "best" for If the concern is the existence of
I like this most in terms of "testable but straightforward API". I'm not sure if there's any use case beyond testing, but at least this would not be as much of a foot-gun as other approaches.
Hm... I don't love not having tests relevant to backported changes. Overall, given that above points, my opinion is that However, I will defer to you, and try out a second commit that exposes Does this sound good? |
Trying out the options: Tidying up naming / minimizing excess in public header: f5c22ac Using Demoting |
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Yes, it is 100% implementation dependent. But the implementation is in this package, so anything that changes the implementation will have to update the tests as well. That seems like a reasonable thing in my opinion. Note that I also ended up pushing 39371e8 , which cleans up some things. In particular, it switches |
I think it's great to update the tests, and I think any of the methods (including My concern is more about backwards-compatibility with consumers external to this package. By adding this method in a fashion that is accessible, it is exposing this package to perhaps over-burdensome constraints. (this is where Is there guidance in ROS 2 dev documentation regarding how aggressive stability promises are (or aren't) for API? For example, in Drake, we have https://drake.mit.edu/stable.html |
Yes, we never break API during a stable release (or, at least, we have to have a severe bug to warrant it): http://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Developer-Guide.html#versioning . However, we do have an exception for things that are internal (though that is not documented). I'm totally on board with marking |
Sweet, thanks! I think For this PR, is there anything else necessary for it to land? |
Per #680 (comment), looks like there are downstream tests that are sensitive the specific ordering of insertion. Not sure if there is anything that should be done here, aside from perhaps updating the test to state "insertion ordering is actually important for testing in |
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Windows (correctly) warned about loss of precision in one of the calls. I fixed that in cff49f6, here is CI again: |
https://github.com/Mergifyio backport jazzy humble iron |
✅ Backports have been created
|
…ng (#678) * [cache_unittest] Add direct implementation testing on ordering, pruning * do getAllItems() approach * Return a reference instead. * mark getAllItems as internal * Fix warning on Windows. Co-authored-by: Chris Lalancette <clalancette@gmail.com> (cherry picked from commit a17a2bf) # Conflicts: # tf2/include/tf2/time_cache.h
…ng (#678) * [cache_unittest] Add direct implementation testing on ordering, pruning * do getAllItems() approach * Return a reference instead. * mark getAllItems as internal * Fix warning on Windows. Co-authored-by: Chris Lalancette <clalancette@gmail.com> (cherry picked from commit a17a2bf) # Conflicts: # tf2/include/tf2/time_cache.h
…ng (#678) (#687) * [cache_unittest] Add direct implementation testing on ordering, pruning * do getAllItems() approach * Return a reference instead. * mark getAllItems as internal * Fix warning on Windows. Co-authored-by: Chris Lalancette <clalancette@gmail.com> (cherry picked from commit a17a2bf) Co-authored-by: Eric Cousineau <eric.cousineau@tri.global>
Towards #676
This changes nothing pertaining to the implementation. It only adds testing.
Some of it is implementation-specific, but towards the ends of performance checks.
From #676 (comment)
To answer them:
ImplSortedDescendingUniqueEntries
ImplSortedDescendingUniqueEntries
ImplSortedDescendingUniqueEntries
ImplSortedDescendingUniqueEntries