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

Test initializing parameters from command line #274

Merged
merged 16 commits into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.5)

project(test_cli)

find_package(ament_cmake_auto REQUIRED)

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

find_package(ament_cmake REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(ament_cmake_pytest REQUIRED)
find_package(rclcpp REQUIRED)

ament_lint_auto_find_test_dependencies()

add_executable(initial_params_rclcpp
test/initial_params.cpp)
ament_target_dependencies(initial_params_rclcpp
"rclcpp")

ament_add_pytest_test(test_params_yaml
test/test_params_yaml.py
ENV
INITIAL_PARAMS_RCLCPP=$<TARGET_FILE:initial_params_rclcpp>
TIMEOUT 120)
set_tests_properties(test_params_yaml
PROPERTIES DEPENDS
initial_params_rclcpp)
endif()

ament_auto_package()
28 changes: 28 additions & 0 deletions test_cli/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>test_cli</name>
<version>0.4.0</version>
<description>
Test command line arguments passed to ros2 executables.
</description>
<maintainer email="sloretz@openrobotics.org">Shane Loretz</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<build_depend>ament_cmake</build_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>launch</test_depend>
Copy link
Member

Choose a reason for hiding this comment

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

Seems like an unused dependency?

<test_depend>rclcpp</test_depend>
<test_depend>rcl_interfaces</test_depend>
<test_depend>ros2param</test_depend>
<test_depend>rclpy</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Empty file added test_cli/test/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions test_cli/test/initial_params.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2018 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <string>
#include <vector>

#include "rclcpp/rclcpp.hpp"

int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);

std::string node_name = "initial_params_node";
std::string namespace_ = "/";
auto node = rclcpp::Node::make_shared(node_name, namespace_);

rclcpp::spin(node);

rclcpp::shutdown();
return 0;
}
Loading