-
Notifications
You must be signed in to change notification settings - Fork 170
Expose StringJoinSubstitution to frontend #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christophebedard
merged 15 commits into
ros2:rolling
from
baconbrot:stringjoinsubstitution_frontend
Oct 23, 2025
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
97839d1
Expose StringJoinSubstitution to frontend
baconbrot 67e708b
Fix type and flake error
baconbrot 35ceba5
Wrap data in iter instead of normalizing here
baconbrot dd146aa
Update launch/launch/substitutions/string_join_substitution.py
baconbrot d07a093
Set explicit dict type for frontend kwargs
baconbrot 0334554
Add xml and yaml test
baconbrot 3243a78
Add xml and yaml exmaple to docstring
baconbrot 09f2924
Remove trailing whitespace
baconbrot 54ca555
Update launch/launch/substitutions/string_join_substitution.py
baconbrot 425d0f2
Use ld.entities instead of describe_sub_entities as of https://github…
baconbrot 49dee17
Update type hints according to https://github.com/ros2/launch/pull/85…
baconbrot b964aec
Update launch_xml/test/launch_xml/test_string_join_substitution.py
baconbrot 31274aa
Update launch_xml/test/launch_xml/test_string_join_substitution.py
baconbrot 08ca43d
Update launch_yaml/test/launch_yaml/test_string_join_substitution.py
baconbrot 2ace3af
Update launch_yaml/test/launch_yaml/test_string_join_substitution.py
baconbrot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
launch_xml/test/launch_xml/test_string_join_substitution.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright 2025 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Test parsing a StringJoinSubstitution in XML launch file.""" | ||
|
|
||
| import io | ||
| import textwrap | ||
|
|
||
| from launch.actions import DeclareLaunchArgument, SetLaunchConfiguration | ||
| from launch.frontend import Parser | ||
| from launch.launch_context import LaunchContext | ||
| from launch.substitutions import StringJoinSubstitution | ||
|
|
||
|
|
||
| def test_nested(): | ||
| xml_file = textwrap.dedent( | ||
| """ | ||
| <launch> | ||
| <arg name="subdomain" default="wiki"/> | ||
| <let name="url" value="$(string-join . https://$(var subdomain) ros org)"/> | ||
| </launch> | ||
| """ | ||
| ) | ||
| root_entity, parser = Parser.load(io.StringIO(xml_file)) | ||
| ld = parser.parse_description(root_entity) | ||
|
|
||
| assert len(ld.entities) == 2 | ||
| assert isinstance(ld.entities[0], DeclareLaunchArgument) | ||
| assert isinstance(ld.entities[1], SetLaunchConfiguration) | ||
|
|
||
| lc = LaunchContext() | ||
| ld.entities[0].visit(lc) | ||
|
|
||
| let = ld.describe_sub_entities()[1] | ||
| assert isinstance(let.value[0], StringJoinSubstitution) | ||
| assert let.value[0].perform(lc) == 'https://wiki.ros.org' | ||
|
|
||
|
|
||
| def test_delimiter(): | ||
| yaml_file = textwrap.dedent( | ||
| """ | ||
| <launch> | ||
| <arg name="delimiter" default="^_^"/> | ||
| <let name="text" value="$(string-join '($(var delimiter))' a b c)"/> | ||
| </launch> | ||
| """ | ||
| ) | ||
| root_entity, parser = Parser.load(io.StringIO(yaml_file)) | ||
| ld = parser.parse_description(root_entity) | ||
|
|
||
| assert len(ld.entities) == 2 | ||
| assert isinstance(ld.entities[0], DeclareLaunchArgument) | ||
| assert isinstance(ld.entities[1], SetLaunchConfiguration) | ||
|
|
||
| lc = LaunchContext() | ||
| ld.entities[0].visit(lc) | ||
|
|
||
| let = ld.describe_sub_entities()[1] | ||
|
baconbrot marked this conversation as resolved.
Outdated
|
||
| assert isinstance(let.value[0], StringJoinSubstitution) | ||
| assert let.value[0].perform(lc) == 'a(^_^)b(^_^)c' | ||
77 changes: 77 additions & 0 deletions
77
launch_yaml/test/launch_yaml/test_string_join_substitution.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Copyright 2025 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Test parsing a StringJoinSubstitution in yaml launch file.""" | ||
|
|
||
| import io | ||
| import textwrap | ||
|
|
||
| from launch.actions import DeclareLaunchArgument, SetLaunchConfiguration | ||
| from launch.frontend import Parser | ||
| from launch.launch_context import LaunchContext | ||
| from launch.substitutions import StringJoinSubstitution | ||
|
|
||
|
|
||
| def test_nested(): | ||
| yaml_file = textwrap.dedent( | ||
| """ | ||
| launch: | ||
| - arg: | ||
| name: subdomain | ||
| default: "wiki" | ||
| - let: | ||
| name: url | ||
| value: "$(string-join . https://$(var subdomain) ros org)" | ||
| """ | ||
| ) | ||
| root_entity, parser = Parser.load(io.StringIO(yaml_file)) | ||
| ld = parser.parse_description(root_entity) | ||
|
|
||
| assert len(ld.entities) == 2 | ||
| assert isinstance(ld.entities[0], DeclareLaunchArgument) | ||
| assert isinstance(ld.entities[1], SetLaunchConfiguration) | ||
|
|
||
| lc = LaunchContext() | ||
| ld.entities[0].visit(lc) | ||
|
|
||
| let = ld.describe_sub_entities()[1] | ||
|
baconbrot marked this conversation as resolved.
Outdated
|
||
| assert isinstance(let.value[0], StringJoinSubstitution) | ||
| assert let.value[0].perform(lc) == 'https://wiki.ros.org' | ||
|
|
||
|
|
||
| def test_delimiter(): | ||
| yaml_file = textwrap.dedent( | ||
| """ | ||
| launch: | ||
| - arg: | ||
| name: delimiter | ||
| default: "^_^" | ||
| - let: | ||
| name: text | ||
| value: "$(string-join '($(var delimiter))' a b c)" | ||
| """ | ||
| ) | ||
| root_entity, parser = Parser.load(io.StringIO(yaml_file)) | ||
| ld = parser.parse_description(root_entity) | ||
|
|
||
| assert len(ld.entities) == 2 | ||
| assert isinstance(ld.entities[0], DeclareLaunchArgument) | ||
| assert isinstance(ld.entities[1], SetLaunchConfiguration) | ||
|
|
||
| lc = LaunchContext() | ||
| ld.entities[0].visit(lc) | ||
|
|
||
| let = ld.describe_sub_entities()[1] | ||
|
baconbrot marked this conversation as resolved.
Outdated
|
||
| assert isinstance(let.value[0], StringJoinSubstitution) | ||
| assert let.value[0].perform(lc) == 'a(^_^)b(^_^)c' | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.