Skip to content

Commit cb346a1

Browse files
committed
Fix the unit test for humble compatibilty
1 parent fa4c667 commit cb346a1

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

test/launch/basic_launch.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,11 @@
1313
# limitations under the License.
1414

1515
from launch_frontend_py import launch
16-
from launch_frontend_py.actions import arg, log
16+
from launch_frontend_py.actions import arg, executable
1717

1818

1919
def generate_launch_description():
2020
return launch([
21-
arg(name='foo', default='bar'),
22-
log(
23-
level='INFO',
24-
message='I am a launch file: foo=$(var foo)',
25-
),
26-
# TODO(emerson) make if_ work
27-
# log(
28-
# if_='$(var foo)',
29-
# level='INFO',
30-
# message='This conditional log only happened because foo is true',
31-
# ),
32-
# log(
33-
# if_='$(not $(var foo))',
34-
# level='INFO',
35-
# message='This conditional log only happened because foo is false',
36-
# ),
21+
arg(name='message', default='hello world'),
22+
executable(cmd='echo $(var message)', output='both'),
3723
])

test/test_frontend.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,34 @@
1515
from pathlib import Path
1616

1717
from launch import LaunchContext, LaunchDescription
18-
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, Log
19-
from launch.utilities import perform_substitutions
18+
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
2019

2120
THIS_DIR = Path(__file__).parent
2221

2322

2423
def test_load_basic():
2524
context = LaunchContext()
2625

27-
include = IncludeLaunchDescription(THIS_DIR / 'launch' / 'basic_launch.py')
26+
include = IncludeLaunchDescription(str(THIS_DIR / 'launch' / 'basic_launch.py'))
27+
print(include)
2828
included_entities = include.get_sub_entities()
29+
print(included_entities)
30+
assert len(included_entities) == 1
31+
2932
launch_desc = included_entities[0]
3033
assert isinstance(launch_desc, LaunchDescription)
3134

3235
launchfile_entities = launch_desc.describe_sub_entities()
3336
assert len(launchfile_entities) == 2
3437

38+
# The first entity is a declare()
3539
should_be_declare = launchfile_entities[0]
36-
should_be_log = launchfile_entities[1]
37-
3840
assert isinstance(should_be_declare, DeclareLaunchArgument)
3941
should_be_declare.visit(context)
4042

41-
assert isinstance(should_be_log, Log)
42-
should_be_log.visit(context)
43+
# Second is executable()
44+
should_be_exec = launchfile_entities[1]
45+
assert isinstance(should_be_exec, ExecuteProcess)
4346

44-
msg = perform_substitutions(context, should_be_log.msg)
45-
assert msg == 'I am a launch file: foo=bar'
47+
should_be_exec.prepare(context)
48+
assert should_be_exec.process_description.final_cmd == ['echo', 'hello world']

0 commit comments

Comments
 (0)