Skip to content

Commit

Permalink
roslaunch-check: Search dir recursively (#1914)
Browse files Browse the repository at this point in the history
* roslaunch-check: Search dir recursively

This will simply check all .launch files in the directory you pass, including
subdirectories. I recently set up roslaunch-check on a CI server, and
missed having a feature like this.

However, the directory you pass must still be a ROS package
or a subdirectory of a ROS package. If you have, say, a dir
containing many packages, and you want to check every launch
file in every package in that dir, then you'll need to invoke
roslaunch-check once for each package.

* roslaunch-check: Don't search hidden folders
  • Loading branch information
mortenfyhn authored Apr 27, 2020
1 parent 7a775b6 commit c1722c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tools/roslaunch/scripts/roslaunch-check
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from __future__ import print_function

import fnmatch
import os
import sys

Expand All @@ -50,12 +51,14 @@ def check_roslaunch_file(roslaunch_file, use_test_depends=False, ignore_unset_ar
return "[%s]:\n\t%s"%(roslaunch_file,error_msg)

def check_roslaunch_dir(roslaunch_dir, use_test_depends=False, ignore_unset_args=False):
roslaunch_files = []
for dirpath, dirnames, filenames in os.walk(roslaunch_dir):
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in fnmatch.filter(filenames, "*.launch"):
roslaunch_files.append(os.path.join(dirpath, filename))
error_msgs = []
for f in os.listdir(roslaunch_dir):
if f.endswith('.launch'):
roslaunch_file = os.path.join(roslaunch_dir, f)
if os.path.isfile(roslaunch_file):
error_msgs.append(check_roslaunch_file(roslaunch_file, use_test_depends=use_test_depends, ignore_unset_args=ignore_unset_args))
for roslaunch_file in roslaunch_files:
error_msgs.append(check_roslaunch_file(roslaunch_file, use_test_depends=use_test_depends, ignore_unset_args=ignore_unset_args))
# error message has to be XML attr safe
return '\n'.join([e for e in error_msgs if e])

Expand Down

0 comments on commit c1722c7

Please sign in to comment.