File tree Expand file tree Collapse file tree 4 files changed +23
-6
lines changed
test/launch/substitutions Expand file tree Collapse file tree 4 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1717from typing import Sequence
1818from typing import Text
1919
20+ from .path_join_substitution import PathSubstitution
2021from ..frontend .expose import expose_substitution
2122from ..launch_context import LaunchContext
2223from ..logging import launch_config as launch_logging_config
2324from ..some_substitutions_type import SomeSubstitutionsType
24- from ..substitution import Substitution
2525
2626
2727@expose_substitution ('launch_log_dir' )
2828@expose_substitution ('log_dir' )
29- class LaunchLogDir (Substitution ):
29+ class LaunchLogDir (PathSubstitution ):
3030 """Substitution that returns the absolute path to the current launch log directory."""
3131
3232 def __init__ (self ) -> None :
3333 """Create a LaunchLogDir substitution."""
34- super ().__init__ ()
34+ super ().__init__ (path = self )
3535
3636 @classmethod
3737 def parse (cls , data : Sequence [SomeSubstitutionsType ]):
Original file line number Diff line number Diff line change 1717from typing import Sequence
1818from typing import Text
1919
20+ from .path_join_substitution import PathSubstitution
2021from .substitution_failure import SubstitutionFailure
2122from ..frontend .expose import expose_substitution
2223from ..launch_context import LaunchContext
2324from ..some_substitutions_type import SomeSubstitutionsType
24- from ..substitution import Substitution
2525
2626
2727@expose_substitution ('dirname' )
28- class ThisLaunchFileDir (Substitution ):
28+ class ThisLaunchFileDir (PathSubstitution ):
2929 """Substitution that returns the absolute path to the current launch file."""
3030
3131 def __init__ (self ) -> None :
3232 """Create a ThisLaunchFileDir substitution."""
33- super ().__init__ ()
33+ super ().__init__ (path = self )
3434
3535 @classmethod
3636 def parse (cls , data : Sequence [SomeSubstitutionsType ]):
Original file line number Diff line number Diff line change @@ -32,6 +32,14 @@ def test_launch_log_dir_methods():
3232 assert lld .perform (lc )
3333
3434
35+ def test_launch_log_dir_path ():
36+ test_dir = LaunchLogDir () / 'subdir'
37+ lc = LaunchContext ()
38+ result = test_dir .perform (lc )
39+ assert result
40+ assert result .endswith ('subdir' )
41+
42+
3543def test_launch_log_dir_frontend ():
3644 """Test launch_log_dir/log_dir frontend substitutions."""
3745 for sub in ('launch_log_dir' , 'log_dir' ):
Original file line number Diff line number Diff line change 1414
1515"""Tests for the ThisLaunchFileDir substitution class."""
1616
17+ import os
18+
1719from launch import LaunchContext
1820from launch .substitutions import SubstitutionFailure
1921from launch .substitutions import ThisLaunchFileDir
@@ -35,3 +37,10 @@ def test_this_launch_file_path_methods():
3537 tlfp .perform (lc )
3638 lc .extend_locals ({'current_launch_file_directory' : 'foo' })
3739 assert tlfp .perform (lc ) == 'foo'
40+
41+
42+ def test_this_launch_file_dir_pathing ():
43+ test_file = ThisLaunchFileDir () / 'some_launch.xml'
44+ lc = LaunchContext ()
45+ lc .extend_locals ({'current_launch_file_directory' : 'foo' })
46+ assert test_file .perform (lc ) == os .path .join ('foo' , 'some_launch.xml' )
You can’t perform that action at this time.
0 commit comments