-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlaunch_turtle.py
More file actions
44 lines (37 loc) · 1.22 KB
/
launch_turtle.py
File metadata and controls
44 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import unittest
import sys
import os
import pytest
import launch_testing
from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch_ros.actions import Node
ARTEFACTS_PARAMS_FILE = os.environ.get(
"ARTEFACTS_SCENARIO_PARAMS_FILE", {}
)
@pytest.mark.launch_test
def generate_test_description():
proc_env = os.environ.copy()
proc_env['PYTHONUNBUFFERED'] = '1'
# TODO switch to package
sample_process = ExecuteProcess(
cmd=[sys.executable, "sample_node.py"],
output="log", env=proc_env)
rosbag_cmd = ['ros2', 'bag', 'record', '-a']
bag_recorder = ExecuteProcess(
cmd=rosbag_cmd,
output='screen', env=proc_env)
return LaunchDescription([
Node(
package="turtlesim",
executable='turtlesim_node',
parameters=[ARTEFACTS_PARAMS_FILE],
),
bag_recorder,
sample_process,
launch_testing.actions.ReadyToTest()
]), {"sample_process": sample_process}
class TestTurtle(unittest.TestCase):
def test_tank_reach_target(self, proc_output, sample_process):
# This will match stdout from test_process.
proc_output.assertWaitFor("Turtle nearing right edge", timeout=5)