forked from ros2/launch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up access to substituted values
Modified handling of cmd parameter as described in ros2#263 Distro A; OPSEC #2893 Signed-off-by: Roger Strain <rstrain@swri.org>
- Loading branch information
Showing
2 changed files
with
73 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,32 @@ | ||
# import pytest | ||
from launch.descriptions.executable import Executable | ||
from launch.launch_context import LaunchContext | ||
|
||
|
||
def test_executable(): | ||
exe = Executable(cmd="test") | ||
assert exe is not None | ||
|
||
|
||
def test_cmd_simple_string(): | ||
exe = Executable(cmd='ls "my/subdir/with spaces/"') | ||
exe.apply_context(LaunchContext()) | ||
assert all([a == b for a, b in zip(exe.final_cmd, ['ls', 'my/subdir/with spaces/'])]) | ||
|
||
|
||
def test_cmd_string_in_list(): | ||
exe = Executable(cmd=['ls "my/subdir/with spaces/"']) | ||
exe.apply_context(LaunchContext()) | ||
assert all([a == b for a, b in zip(exe.final_cmd, ['ls', 'my/subdir/with spaces/'])]) | ||
|
||
|
||
def test_cmd_strings_in_list(): | ||
exe = Executable(cmd=['ls', '"my/subdir/with spaces/"']) | ||
exe.apply_context(LaunchContext()) | ||
assert all([a == b for a, b in zip(exe.final_cmd, ['ls', 'my/subdir/with spaces/'])]) | ||
|
||
|
||
def test_cmd_multiple_arguments_in_string(): | ||
exe = Executable(cmd=['ls', '-opt1', '-opt2', '-opt3']) | ||
exe.apply_context(LaunchContext()) | ||
assert all([a == b for a, b in zip(exe.final_cmd, ['ls', '-opt1', '-opt2', '-opt3'])]) |