rostest: roslaunch-check.py now support #2154 (directories)

This commit is contained in:
Ken Conley 2010-04-08 01:49:41 +00:00
parent 18ac7632f3
commit d1884c815b
4 changed files with 40 additions and 20 deletions

View File

@ -31,7 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id: catunit 3804 2009-02-11 02:16:00Z rob_wheeler $
# Revision $Id$
"""
Cleanunit is a simple script that takes all the xml-formatted unit

View File

@ -31,7 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id: __init__.py 6720 2009-11-07 02:09:56Z kwc $
# Revision $Id$
"""
Generate HTML reports from coverage.py (aka python-coverage). This is

View File

@ -31,7 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id: catunit 3804 2009-02-11 02:16:00Z rob_wheeler $
# Revision $Id$
from __future__ import with_statement
import roslib; roslib.load_manifest('rostest')
@ -41,39 +41,60 @@ import sys
import roslib.packages
import roslaunch.rlutil
def usage():
print >> sys.stderr, """Usage:
\troslaunch-check file.launch
\troslaunch-check [file|directory]
"""
print sys.argv
sys.exit(os.EX_USAGE)
def check_roslaunch(f):
pass
def check_roslaunch_file(roslaunch_file):
print "checking", roslaunch_file
error_msg = roslaunch.rlutil.check_roslaunch(roslaunch_file)
if error_msg:
return "[%s]:\n\t%s"%(roslaunch_file,error_msg)
def check_roslaunch_dir(roslaunch_dir):
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))
return '\n'.join([e for e in error_msgs if e])
## run check and output test result file
if __name__ == '__main__':
if len(sys.argv) < 2:
usage()
roslaunch_file = sys.argv[1]
_, package = roslib.packages.get_dir_pkg(roslaunch_file)
import roslaunch.rlutil
import rostest.rostestutil
roslaunch_path = sys.argv[1]
pkg_dir, pkg = roslib.packages.get_dir_pkg(roslaunch_path)
if os.path.isfile(roslaunch_path):
error_msg = check_roslaunch_file(roslaunch_path)
outname = os.path.basename(roslaunch_path).replace('.', '_')
else:
print "checking *.launch in directory", roslaunch_path
error_msg = check_roslaunch_dir(roslaunch_path)
outname = os.path.relpath(os.path.abspath(roslaunch_path), pkg_dir).replace(os.sep, '_')
if outname == '.':
outname = '_pkg'
import rostest.rostestutil
test_file = rostest.rostestutil.xmlResultsFile(pkg, "roslaunch_check_"+outname, is_rostest=False)
pkg_dir, pkg = roslib.packages.get_dir_pkg(roslaunch_file)
outname = os.path.basename(roslaunch_file).replace('.', '_')
test_file = rostest.rostestutil.xmlResultsFile(pkg, outname, is_rostest=False)
error_msg = roslaunch.rlutil.check_roslaunch(roslaunch_file)
test_name = roslaunch_file
print "...writing test results to", test_file
test_name = roslaunch_path
if error_msg:
print>> sys.stderr, "FAILURE:\n%s"%error_msg
if not os.path.exists(os.path.dirname(test_file)):
os.makedirs(os.path.dirname(test_file))
with open(test_file, 'w') as f:
message = "roslaunch file %s failed to parse:\n %s"%(roslaunch_file, error_msg)
message = "roslaunch check [%s] failed:\n %s"%(roslaunch_path, error_msg)
f.write(rostest.rostestutil.test_failure_junit_xml(test_name, message))
f.close()
print "wrote test file to [%s]"%test_file
@ -81,4 +102,3 @@ if __name__ == '__main__':
print "passed"
with open(test_file, 'w') as f:
f.write(rostest.rostestutil.test_success_junit_xml(test_name))

View File

@ -31,7 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id: catunit 3804 2009-02-11 02:16:00Z rob_wheeler $
# Revision $Id$
"""test-results-dir simply prints the directory that test_results are stored in"""