|
| 1 | +# Copyright 2019 Open Source Robotics Foundation, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import os |
| 16 | +import unittest |
| 17 | + |
| 18 | +import ament_index_python |
| 19 | +from launch import LaunchDescription |
| 20 | +from launch import LaunchService |
| 21 | +from launch.actions import ExecuteProcess |
| 22 | +from launch.actions import OpaqueFunction |
| 23 | +import launch_testing |
| 24 | +import launch_testing.asserts |
| 25 | + |
| 26 | + |
| 27 | +def generate_test_description(ready_fn): |
| 28 | + launch_description = LaunchDescription() |
| 29 | + |
| 30 | + launch_description.add_action( |
| 31 | + ExecuteProcess( |
| 32 | + cmd=[ |
| 33 | + os.path.join( |
| 34 | + ament_index_python.get_package_prefix('test_launch_ros'), |
| 35 | + 'bin', |
| 36 | + 'mock-composable-container'), |
| 37 | + ], |
| 38 | + ) |
| 39 | + ) |
| 40 | + |
| 41 | + launch_description.add_action( |
| 42 | + OpaqueFunction(function=lambda context: ready_fn()) |
| 43 | + ) |
| 44 | + return launch_description, locals() |
| 45 | + |
| 46 | + |
| 47 | +class TestComposition(unittest.TestCase): |
| 48 | + |
| 49 | + def test_hello_world(self): |
| 50 | + raise Exception(repr(self.proc_info._proc_info_handler._proc_info)) |
| 51 | + proc = self.proc_info.processes()[0] |
| 52 | + launch_testing.asserts.assertInStdout(self.proc_output, 'Hello world', proc) |
| 53 | + |
| 54 | + |
| 55 | +# @launch_testing.post_shutdown_test() |
| 56 | +# class TestTwoExecutablesAfterShutdown(unittest.TestCase): |
| 57 | +# |
| 58 | +# def @TEST_NAME@(self, executable_under_test): |
| 59 | +# """Test that the executable under test finished cleanly.""" |
| 60 | +# launch_testing.asserts.assertExitCodes(self.proc_info, process=executable_under_test) |
0 commit comments