|
| 1 | +import unittest |
| 2 | + |
| 3 | +from launch import LaunchDescription |
| 4 | +from launch_ros.actions import SetParameter |
| 5 | +from launch.actions import DeclareLaunchArgument, ExecuteProcess, SetEnvironmentVariable |
| 6 | +from launch.substitutions import LaunchConfiguration |
| 7 | + |
| 8 | +import launch_testing |
| 9 | +import launch_testing.actions |
| 10 | +import launch_testing.asserts |
| 11 | +import launch_testing.util |
| 12 | + |
| 13 | +def generate_test_description(): |
| 14 | + test_binary = LaunchConfiguration('test_binary') |
| 15 | + timeout = LaunchConfiguration('timeout') |
| 16 | + |
| 17 | + test_proc = ExecuteProcess( |
| 18 | + cmd=[test_binary], |
| 19 | + name='ros_interface_test', |
| 20 | + output='screen', |
| 21 | + ) |
| 22 | + return LaunchDescription([ |
| 23 | + DeclareLaunchArgument('test_binary'), |
| 24 | + DeclareLaunchArgument('timeout', default_value="10"), |
| 25 | + SetEnvironmentVariable( |
| 26 | + 'ROSCONSOLE_FORMAT', |
| 27 | + '[${severity}] [${time}] [${logger}] [${node}]: ${message}' |
| 28 | + ), |
| 29 | + SetParameter(name='use_sim_time', value=True), |
| 30 | + test_proc, |
| 31 | + launch_testing.util.KeepAliveProc(), |
| 32 | + launch_testing.actions.ReadyToTest(), |
| 33 | + ]), { |
| 34 | + 'test_proc': test_proc, |
| 35 | + 'timeout': timeout, |
| 36 | + } |
| 37 | + |
| 38 | +class TestGTestWaitForCompletion(unittest.TestCase): |
| 39 | + def test_gtest_run_complete(self, proc_info, test_proc): |
| 40 | + proc_info.assertWaitForShutdown(test_proc) |
| 41 | + |
| 42 | +@launch_testing.post_shutdown_test() |
| 43 | +class TestGTestProcessPostShutdown(unittest.TestCase): |
| 44 | + def test_gtest_pass(self, proc_info, test_proc): |
| 45 | + launch_testing.asserts.assertExitCodes(proc_info, process=test_proc) |
0 commit comments