Skip to content

Commit 0665f21

Browse files
committed
Get package share directory using ament_index_python
Signed-off-by: Gonzalo de Pedro <[email protected]>
1 parent e08db98 commit 0665f21

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

rosidl_typesupport_protobuf_c/test/test_rosidl_cli_ts_pb_c.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shutil
55
import subprocess
66

7+
from ament_index_python import get_package_share_directory
78

89
def test_ts_files_generation():
910
build_then_install('/tmp/pb')
@@ -14,11 +15,12 @@ def build_then_install(output_path):
1415
shutil.rmtree(output_path)
1516
os.makedirs(output_path)
1617

17-
#rosidl generate -ts protobuf_c -o /tmp/pb std_msgs ./install/std_msgs/share/std_msgs/msg/String.msg
18-
18+
package_share_path = pathlib.Path(
19+
get_package_share_directory('std_msgs'))
20+
1921
subprocess.run([
2022
'rosidl', 'generate', '-ts', 'protobuf_c', '-o', output_path, 'std_msgs', './msg/String.msg'
21-
], cwd='/home/aeten/ros2_rolling/install/std_msgs/share/std_msgs', check=True)
23+
], cwd=package_share_path, check=True)
2224

2325
def files_exists(output_path):
2426
assert pathlib.Path('/tmp/pb/tmp/msg/String.idl').exists()

rosidl_typesupport_protobuf_cpp/test/test_rosidl_cli_ts_pb_cpp.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shutil
55
import subprocess
66

7+
from ament_index_python import get_package_share_directory
78

89
def test_ts_files_generation():
910
build_then_install('/tmp/pb')
@@ -14,11 +15,12 @@ def build_then_install(output_path):
1415
shutil.rmtree(output_path)
1516
os.makedirs(output_path)
1617

17-
#rosidl generate -ts protobuf_c -o /tmp/pb std_msgs ./install/std_msgs/share/std_msgs/msg/String.msg
18-
18+
package_share_path = pathlib.Path(
19+
get_package_share_directory('std_msgs'))
20+
1921
subprocess.run([
2022
'rosidl', 'generate', '-ts', 'protobuf_cpp', '-o', output_path, 'std_msgs', './msg/String.msg'
21-
], cwd='/home/aeten/ros2_rolling/install/std_msgs/share/std_msgs', check=True)
23+
], cwd=package_share_path, check=True)
2224

2325
def files_exists(output_path):
2426
assert pathlib.Path('/tmp/pb/tmp/msg/String.idl').exists()

0 commit comments

Comments
 (0)