Skip to content
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

Merged
merged 10 commits into from
Jun 5, 2018
Merged

Add tests for command line remapping #268

merged 10 commits into from
Jun 5, 2018

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented May 2, 2018

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.

@sloretz sloretz added the in progress Actively being worked on (Kanban column) label May 2, 2018
@sloretz sloretz self-assigned this May 2, 2018
@sloretz
Copy link
Contributor Author

sloretz commented May 2, 2018

CI

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz
Copy link
Contributor Author

sloretz commented May 10, 2018

New CI

@sloretz sloretz added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels May 10, 2018
Copy link
Member

@mikaelarguedas mikaelarguedas left a 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 ?


<buildtool_depend>ament_cmake_auto</buildtool_depend>

<exec_depend>test_msgs</exec_depend>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<build_depend>test_msgs</build_depend>
<build_depend>rclcpp</build_depend>
<build_depend>ament_cmake</build_depend>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1ec7f4d then removed them in 77a1140


add_executable(name_maker_rclcpp
test/name_maker.cpp)
target_compile_features(name_maker_rclcpp PRIVATE cxx_lambdas)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary ?

Copy link
Contributor Author

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)

Copy link
Member

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 ?

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<license>Apache License 2.0</license>

<build_depend>test_msgs</build_depend>
<build_depend>rclcpp</build_depend>
Copy link
Member

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 ?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project(test_cli_remapping)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: typo: enironment

Copy link
Contributor Author

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)
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

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 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%r -> "%s"
327c0fd

@sloretz sloretz added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels May 16, 2018
@sloretz sloretz force-pushed the test_cli_remapping branch from 68fb36c to 1fe0d27 Compare May 18, 2018 15:29
@sloretz
Copy link
Contributor Author

sloretz commented May 18, 2018

Thanks for the review @mikaelarguedas

Remapping doesn't need coroutines. They are a consequence of ros2/launch#51. launch can't launch executables in a non-main thread, so launch is using the main thread to both monitor the name_maker and execute the test logic. I think I could avoid coroutines by using subprocess directly.

@sloretz
Copy link
Contributor Author

sloretz commented May 18, 2018

Running CI Linux first Build Status

@sloretz
Copy link
Contributor Author

sloretz commented May 18, 2018

Full CI, back in review

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz sloretz added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels May 18, 2018
@mikaelarguedas mikaelarguedas self-requested a review May 31, 2018 17:08
Copy link
Member

@mikaelarguedas mikaelarguedas left a 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:
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this PR as is since it adds test coverage, though in the future I hope to combine test_cli_remapping with test_cli which will be added in #274. To that end I fixed this in ec67875.

I'll create a ticket to merge the two after #274 is merged.

@sloretz sloretz merged commit e95f4f5 into master Jun 5, 2018
@sloretz sloretz deleted the test_cli_remapping branch June 5, 2018 20:48
@dirk-thomas
Copy link
Member

The tests introduced in this PR are failing on the Windows debug nightly: https://ci.ros2.org/view/nightly/job/nightly_win_deb/903/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants