-
Notifications
You must be signed in to change notification settings - Fork 129
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 ament_auto_add_gtest #344
Add ament_auto_add_gtest #344
Conversation
That sounds reasonable.
Well, quoting REP-149:
So, I'd expect tests to depend on test dependencies, execution dependencies, and the libraries provided by the package itself (and their build dependencies, but only transitively).
I'd think that
An aspect not covered by this patch is automatic test discovery. A one GTest per file heuristic would probably deal with most typical cases. CC @ament/team for thoughts. |
Basically, exactly what I would expect
Except they don't explicitly do that and I don't know that we want to do that. For example, if you depend on something heafty in building your library (like We definitely don't want to automatically have tests depend on
|
Right, which includes all lint dependencies as a subset. That's what I meant by it finding more than it needs.
We can defer it for now but convergence would be nice, eventually.
Let's back up and build up to a reasonable heuristic for dependencies (which is all this is, a heuristic to cover as many use cases as possible). At the bare minimum, tests have to depend on all package libraries and all test dependencies (that can be found by CMake). Exported build dependencies have to be included as well (explicitly or implicitly through CMake targets). Should build tool dependencies be included? These are dependencies for the build process itself, so probably not. Should build dependencies be included? It'd cover a lot more ground that way. It'll clutter the build graph too, and rely on the toolchain to ignore the unnecessary libraries (which it will, unless explicitly instructed not to do so). That's already the case for test dependencies and build export dependencies though, by virtue of package-level granularity for dependencies (i.e. we can't pick them wisely). Should execution dependencies be included? An execution dependency that affects a test build is already a build dependency or should be a test dependency. So no. I stand corrected there. Since a build dependency is a package needed at build-time, and considering
That's exactly what I meant. The |
@JWhitleyWork friendly ping. |
Signed-off-by: Joshua Whitley <josh.whitley@autoware.org>
Signed-off-by: Joshua Whitley <josh.whitley@autoware.org>
Signed-off-by: Joshua Whitley <josh.whitley@autoware.org>
Thanks for the ping, @hidmic. I have addressed your feedback:
I tested this again on a few Autoware.Auto packages and the following syntax works as expected:
With the above syntax, leaving While I get where you're coming from with regard to the filename-based auto test generation, I think this should be a separate macro such as |
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.
@JWhitleyWork this patch makes sense to me but for one question. Have you linted it?
While I get where you're coming from with regard to the filename-based auto test generation, I think this should be a separate macro such as
ament_auto_add_gtests()
. Additionally, I think this is something that will generate more discussion and seeing as none of the ament team responded, I'd rather keep that in a separate PR if that's OK with you.
Agree on it being a different macro and on deferring it to a follow-up PR. #257 by @cho3 did exercise the idea, so perhaps they may be willing to build on top of your PR?
BTW sorry for the delay to reply. |
@cho3 's open-source contributions appear to have gone silent for the last year or so. I doubt he will be doing this anytime soon. Would you be interested in adding this functionaly? Additionally, would you mind approving this if you're OK with the current implementation? |
Signed-off-by: Joshua Whitley <whitleysoftwareservices@gmail.com>
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.
Test failures appear unrelated. Moving forward here. |
* Add ament_auto_add_gtest * Add ament_auto_find_test_dependencies * Add found build dependencies to ament_auto_add_gtest * Adding dependency on ament_cmake_gtest and fixing lints Signed-off-by: Joshua Whitley <josh.whitley@autoware.org> Co-authored-by: Joshua Whitley <whitleysoftwareservices@gmail.com>
This is an alternative/replacement for #257. Instead of adding a new package, it just extends
ament_cmake_auto
with anament_auto_add_gtest
macro. I've tested this against 10 random packages in Autoware.Auto and it appears to work as expected. However, there are some unanswered questions as to how it should actually work:Question 1
ament_lint_auto_find_test_dependencies()
currently finds alltest_depend
s inpackage.xml
. However, this macro is part ofament_lint_auto
and also triggers the lint hooks. Should I also create anament_auto_find_test_dependencies()
inament_cmake_auto
to replicate thefind_package
functionality without triggering the lint hooks?Question 2
When writing tests, most developers will use packages which are listed as
<build_depend>
or<depend>
inpackage.xml
. These are automaticallyfind_package()
'd byament_auto_find_build_dependencies()
. However, according to REP-149:In addition,
<depend>
only adds a key as<build_depend>
,<build_export_depend>
, and<exec_depend>
- explicitly not as a<test_depend>
. To me, these two things together indicate that the CMake-produced list of test dependencies is not a superset of the listed<build_depend>
s,<buildtool_depend>
s, and<test_depend>
s but is explicitly just the listed<test_depend>
s. If this interpretation is correct, I think most developers are missing a lot of<test_depend>
s and using this macro as currently written will expose that. So, the question is: Should we add allbuild
andbuildtool
depends as dependencies to tests that use this macro or not?