Skip to content

Commit f1e4ee1

Browse files
committed
SLORETZ: partial launch_test composition support
Signed-off-by: Shane Loretz <[email protected]>
1 parent c7f22b1 commit f1e4ee1

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

test_launch_ros/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<test_depend>ament_pep257</test_depend>
1515
<test_depend>demo_nodes_py</test_depend>
1616
<test_depend>launch_ros</test_depend>
17+
<test_depend>launch_testing_ros</test_depend>
1718
<test_depend>python3-pytest</test_depend>
1819
<test_depend>python3-yaml</test_depend>
1920

test_launch_ros/setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@
3232
),
3333
license='Apache License, Version 2.0',
3434
tests_require=['pytest'],
35+
entry_points={
36+
'console_scripts': [
37+
'mock-composable-container=test_launch_ros.mock_composable_container:main'],
38+
}
3539
)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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)

test_launch_ros/test_launch_ros/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
def main():
16+
print('Hello world')

0 commit comments

Comments
 (0)