Permalink
Browse files

Added nosetest for rosdistro files

also fixed a bug in check scripts
  • Loading branch information...
1 parent c7a3aa0 commit 4b5b2f331c45955e4fa44ce7fbc34fe4f1db5176 Paul Mathieu committed Mar 29, 2013
View
No changes.
@@ -115,11 +115,15 @@ def fun(i, l, o):
st.pop()
if len(st) < lvl + 1:
st.append('')
- if re.search(r'^\s?', l) is not None:
+ if re.search(r'^\s*\?', l) is not None:
return True
m = re.match(r'^(?:' + indent_atom + r')*([^:]*):.*$', l)
prev = st[lvl]
- item = m.groups()[0]
+ try:
+ item = m.groups()[0]
+ except:
+ print('woops line %d' % i)
+ raise
st[lvl] = item
if item < prev:
print_err("list out of order line %u" % (i+1))
@@ -129,12 +133,8 @@ def fun(i, l, o):
return generic_parser(buf, fun)
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Checks whether yaml syntax corresponds to ROS rules')
- parser.add_argument('infile', help='input rosdep YAML file')
- args = parser.parse_args()
-
- with open(args.infile) as f:
+def main(fname):
+ with open(fname) as f:
buf = f.read()
def my_assert(val):
@@ -160,6 +160,16 @@ def my_assert(val):
if not my_assert.clean:
printc("there were errors, please correct the file", 'bright red')
+ return False
+ return True
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Checks whether yaml syntax corresponds to ROS rules')
+ parser.add_argument('infile', help='input rosdep YAML file')
+ args = parser.parse_args()
+
+ if not main(args.infile):
sys.exit(1)
@@ -115,11 +115,15 @@ def fun(i, l, o):
st.pop()
if len(st) < lvl + 1:
st.append('')
- if re.search(r'^\s?', l) is not None:
+ if re.search(r'^\s*\?', l) is not None:
return True
m = re.match(r'^(?:' + indent_atom + r')*([^:]*):.*$', l)
prev = st[lvl]
- item = m.groups()[0]
+ try:
+ item = m.groups()[0]
+ except:
+ print('woops line %d' % i)
+ raise
st[lvl] = item
if item < prev:
print_err("list out of order line %u" % (i+1))
@@ -129,12 +133,8 @@ def fun(i, l, o):
return generic_parser(buf, fun)
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Checks whether yaml syntax corresponds to ROS rules')
- parser.add_argument('infile', help='input rosdep YAML file')
- args = parser.parse_args()
-
- with open(args.infile) as f:
+def main(fname):
+ with open(fname) as f:
buf = f.read()
def my_assert(val):
@@ -158,6 +158,16 @@ def my_assert(val):
if not my_assert.clean:
printc("there were errors, please correct the file", 'bright red')
+ return False
+ return True
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Checks whether yaml syntax corresponds to ROS rules')
+ parser.add_argument('infile', help='input rosdep YAML file')
+ args = parser.parse_args()
+
+ if not main(args.infile):
sys.exit(1)
@@ -1,7 +1,7 @@
#!/usr/bin/env python
+from scripts.check_rosdep import main as check_rosdep
import os
-import subprocess
def test():
@@ -17,6 +17,6 @@ def test():
print "Skipping rosdep check of file %s"%fname
continue
print "Checking rosdep file %s" % fname
- assert subprocess.call(['scripts/check_rosdep.py', fname]) == 0
+ assert check_rosdep(fname)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import os
+
+from scripts.check_rosdistro import main as check_rosdist
+
+
+def test():
+ files= os.listdir('releases')
+
+ print """Running scripts/check_rosdistro.py on all *.yaml in the releases directory.
+If this fails you can use the python yaml.dump() method to help cleanup"""
+
+
+ for f in files:
+ fname = os.path.join('releases', f)
+ if not f.endswith('.yaml'):
+ print "Skipping rosdistro check of file %s"%fname
+ continue
+ print "Checking rosdistro file %s" % fname
+ assert check_rosdist(fname)
+
+

0 comments on commit 4b5b2f3

Please sign in to comment.