Skip to content

Commit

Permalink
Use extend and lists more than append()
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <sloretz@google.com>
  • Loading branch information
sloretz committed Mar 28, 2023
1 parent 4df83da commit 371ec23
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
16 changes: 10 additions & 6 deletions test_discovery/roottests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ def ros_ws(pytestconfig):
def make_env_str(ros_ws, rmw, discovery_range, peer):
cmd = []
for ws in ros_ws:
cmd.append('.')
cmd.append(f'"{ws}/setup.bash"')
cmd.append('&&')
cmd.append(f'RMW_IMPLEMENTATION={rmw}')
cmd.append(f'ROS_AUTOMATIC_DISCOVERY_RANGE={discovery_range}')
cmd.append(f'ROS_STATIC_PEERS="{peer}"')
cmd.extend([
'.',
f'"{ws}/setup.bash"',
'&&',
])
cmd.extend([
f'RMW_IMPLEMENTATION={rmw}',
f'ROS_AUTOMATIC_DISCOVERY_RANGE={discovery_range}',
f'ROS_STATIC_PEERS="{peer}"',
])
return ' '.join(cmd)


Expand Down
29 changes: 17 additions & 12 deletions test_discovery/scripts/run_root_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,24 @@ def main():
raise ValueError(f'{args.rmw} is not an installed rmw: {rmw_implementations}')
rmw_implementations = [args.rmw]

cmd = []
cmd.append('sudo')
cmd.append(sys.executable)
cmd.append('-m')
cmd.append('pytest')
cmd.append('-c')
cmd.append(str(get_tests_dir() / 'conftest.py'))
cmd = [
'sudo',
sys.executable,
'-m',
'pytest',
'-c',
str(get_tests_dir() / 'conftest.py'),
]
if args.select:
cmd.append('-k')
cmd.append(args.select)
cmd.append(f'--rmws={":".join(rmw_implementations)}')
cmd.append(f'--ros-workspaces={":".join(get_workspaces())}')
cmd.append(str(get_tests_dir() / 'test_discovery.py'))
cmd.extend([
'-k',
args.select,
])
cmd.extend([
f'--rmws={":".join(rmw_implementations)}',
f'--ros-workspaces={":".join(get_workspaces())}',
str(get_tests_dir() / 'test_discovery.py'),
])

print('Executing the following command:')
print('================================')
Expand Down

0 comments on commit 371ec23

Please sign in to comment.