-
Notifications
You must be signed in to change notification settings - Fork 51
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 command line remapping #268
Conversation
New CI
|
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 logic looks good to me. A few nitpick comments and questions.
Question (sorry if it's obvious, I didn't follow closely the remapping implementation): Is it necessary to do everything with asyncio and coroutines ?
test_cli_remapping/package.xml
Outdated
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
|
||
<exec_depend>test_msgs</exec_depend> |
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.
As this is a test package that doesnt install anything, I think this is not necessary
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_cli_remapping/package.xml
Outdated
|
||
<build_depend>test_msgs</build_depend> | ||
<build_depend>rclcpp</build_depend> | ||
<build_depend>ament_cmake</build_depend> |
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.
Nit: alphabetical order, we usually put the buildtool_depend
before the build_depends
as well
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_cli_remapping/CMakeLists.txt
Outdated
|
||
add_executable(name_maker_rclcpp | ||
test/name_maker.cpp) | ||
target_compile_features(name_maker_rclcpp PRIVATE cxx_lambdas) |
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.
Is this necessary ?
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.
Something like it is. Alternatively I can change this to set_property(TARGET name_maker_rclcpp PROPERTY CXX_STANDARD 11)
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.
Would setting the the CMAKE_CXX_STANDARD globally like we do in the other packages do the job ?
system_tests/test_communication/CMakeLists.txt
Lines 5 to 8 in 84c035d
# Default to C++14 | |
if(NOT CMAKE_CXX_STANDARD) | |
set(CMAKE_CXX_STANDARD 14) | |
endif() |
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.
It would, though I'm not a fan of setting things globally in cmake. I find it easier to debug stuff when I can see what is set on a specific target.
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'm not a fan of setting things globally in cmake
In general I agree.
In this specific case, we do target and rely on c++14 globally in ROS 2 so I think that setting the standard globally should be done in all packages to avoid inconsistency or surprises.
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.
In this specific case, we do target and rely on c++14 globally in ROS 2 so I think that setting the standard globally should be done in all packages to avoid inconsistency or surprises.
Thats a good point for this package. I'll change it.
For downstream users I disagree about it meaning the standard should be set globally. Instead I think ament_target_depenencies()
below should have given the target the standard required to include rclcpp
headers. This would act on a package level like target_compile_features(... PUBLIC ...)
does on a target level.
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_cli_remapping/package.xml
Outdated
<license>Apache License 2.0</license> | ||
|
||
<build_depend>test_msgs</build_depend> | ||
<build_depend>rclcpp</build_depend> |
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.
If nothing these are needed only for testing they should only be test_depends and not build depends right ?
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.
Does test_depends
say something is needed both tests are building and when tests are running?
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.
my understanding is that test_depends are dependencies needed for building and running the tests (things you don't need to have available to build or run the package).
From the REP: When building with testing enabled, the <test_depend> packages are available for configuring and building the tests as well as running them.
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_cli_remapping/CMakeLists.txt
Outdated
project(test_cli_remapping) | ||
|
||
find_package(ament_cmake_auto REQUIRED) | ||
ament_auto_find_build_dependencies() |
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.
If the build dependencies are required to compile we should specify it here (as we should error at CMake configure time if a dependency is missing and not at compile time)
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'm not sure what you mean. Where you looking for explicit find_package()
calls for build dependencies? Added that in 8112882
|
||
auto do_nothing = []( | ||
const test_msgs::srv::Empty::Request::SharedPtr /*request*/, | ||
test_msgs::srv::Empty::Response::SharedPtr /*response*/) -> void |
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 know this is used for testing only but I think misra prefers void casting unused parameters to arguments without a name
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.
|
||
|
||
def get_environment_variable(name): | ||
"""Get enironment variable or raise if it does not exist.""" |
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.
Nit: typo: enironment
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.
"""Get enironment variable or raise if it does not exist.""" | ||
path = os.getenv(name) | ||
if not path: | ||
raise EnvironmentError('Missing environment variable %r' % name) |
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.
Nit: quoting the env var printed.
Also why do we need %r here ?
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.
%r
isn't necessary. I used it to make the output have quotes around name
. "%s"
would work too.
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.
Sounds good, I'm fine either way 👍
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.
%r -> "%s"
327c0fd
68fb36c
to
1fe0d27
Compare
Thanks for the review @mikaelarguedas Remapping doesn't need coroutines. They are a consequence of ros2/launch#51. |
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.
lgtm, thanks for iterating
def get_environment_variable(name): | ||
"""Get environment variable or raise if it does not exist.""" | ||
path = os.getenv(name) | ||
if not 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.
Nit: pedantically this should be if path is None
as some environment can exist and be set but not trigger the if (like an empty string). In the context of this test, it may be more appropriate to expect valid paths and check for path existence rather than empty string or None
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 tests introduced in this PR are failing on the Windows debug nightly: https://ci.ros2.org/view/nightly/job/nightly_win_deb/903/ |
Adds a new package
test_cli_remapping
that checks if command line remapping arguments passed to a process result in changes to the names it uses.