Skip to content

Refactor launch test to use launch substitutions instead of os#3142

Open
AdvityaCode wants to merge 3 commits intoros-controls:masterfrom
AdvityaCode:edits/python_launch_test
Open

Refactor launch test to use launch substitutions instead of os#3142
AdvityaCode wants to merge 3 commits intoros-controls:masterfrom
AdvityaCode:edits/python_launch_test

Conversation

@AdvityaCode
Copy link
Copy Markdown

Closes #2767

Replaces os-based path construction with proper ROS 2 launch substitutions in test_ros2_control_node_launch.py and updates the outdated example in the launch_utils.py docstring.

Changes:

  • Remove import os, get_package_share_directory, and get_package_prefix
  • Replace os.path.join(get_package_prefix(...), ...) with PathJoinSubstitution([FindPackagePrefix(...), ...])
  • Remove the three intermediate local variables (urdf, robot_description_content, robot_description) by inlining the URDF loading using Command(["cat ", PathJoinSubstitution([FindPackageShare(...), ...])])
  • Update the docstring example in launch_utils.py to use PathJoinSubstitution/FindPackageShare instead of os.path.join/get_package_share_directory, and fix the missing quotes around --load-only

Difference from PR #2789:
Another attempt used PathSubstitution (for single path segments) rather than PathJoinSubstitution (for joining multiple path parts), which caused CI failures. This PR also removes the with open(urdf) file-reading block entirely — replacing it with a Command(["cat ", ...]) substitution that is evaluated lazily at launch time rather than eagerly at description-generation time. The docstring fix requested by @christophfroehlich in this comment is also included.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (152ed06) to head (dbdc339).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3142   +/-   ##
=======================================
  Coverage   89.35%   89.35%           
=======================================
  Files         158      158           
  Lines       19392    19388    -4     
  Branches     1573     1573           
=======================================
- Hits        17327    17324    -3     
+ Misses       1419     1418    -1     
  Partials      646      646           
Flag Coverage Δ
unittests 89.35% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...troller_manager/controller_manager/launch_utils.py 22.97% <ø> (ø)
...ller_manager/test/test_ros2_control_node_launch.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

Difference from PR #2789: Another attempt used PathSubstitution (for single path segments) rather than PathJoinSubstitution (for joining multiple path parts), which caused CI failures.

Can you point me to the failing CI? This should work?

The rest LGTM.

@christophfroehlich christophfroehlich added backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted. labels Mar 27, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 1, 2026

This pull request is in conflict. Could you fix it @AdvityaCode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework python launch test

2 participants