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 parameter behavior for rclpy nodes #293

Merged
merged 2 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions test_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if(BUILD_TESTING)
PYTHON_EXECUTABLE "${_PYTHON_EXECUTABLE}"
ENV
INITIAL_PARAMS_RCLCPP=$<TARGET_FILE:initial_params_rclcpp>
INITIAL_PARAMS_RCLPY=${CMAKE_CURRENT_LIST_DIR}/test/initial_params.py
)
set_tests_properties(test_params_yaml
PROPERTIES DEPENDS
Expand Down
31 changes: 31 additions & 0 deletions test_cli/test/initial_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

import sys

import rclpy


def main(argv=sys.argv):
rclpy.init(args=argv)

node = rclpy.create_node('initial_params_node', namespace='/')
rclpy.spin(node)

rclpy.shutdown()
return 0


if __name__ == '__main__':
sys.exit(main())
1 change: 1 addition & 0 deletions test_cli/test/test_params_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

CLIENT_LIBRARY_EXECUTABLES = (
require_environment_variable('INITIAL_PARAMS_RCLCPP'),
require_environment_variable('INITIAL_PARAMS_RCLPY'),
)


Expand Down
1 change: 1 addition & 0 deletions test_cli/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, command):

# Execute python files using same python used to start this test
if command[0][-3:] == '.py':
self._command = list(self._command)
Copy link
Member Author

@nuclearsandwich nuclearsandwich Aug 29, 2018

Choose a reason for hiding this comment

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

This was needed because the tuples that get passed as commands are immutable.

self._command.insert(0, sys.executable)
self._env['PYTHONUNBUFFERED'] = '1'

Expand Down