check-code: put grouping around regexps generated from testpats stable
authorMads Kiilerich <mads@kiilerich.com>
Mon, 23 Apr 2012 01:56:48 +0200
branchstable
changeset 16495 5f9835ed3d6d
parent 16494 e1f0305eabe4
child 16496 abbabbbe4ec2
check-code: put grouping around regexps generated from testpats This removes the pitfall that would make the testpath r'a|b' match 'b' on all lines in .t tests.
contrib/check-code.py
--- a/contrib/check-code.py	Mon Apr 23 01:56:48 2012 +0200
+++ b/contrib/check-code.py	Mon Apr 23 01:56:48 2012 +0200
@@ -43,7 +43,7 @@
 
 testpats = [
   [
-    (r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"),
+    (r'pushd|popd', "don't use 'pushd' or 'popd', use 'cd'"),
     (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
     (r'^function', "don't use 'function', use old style"),
     (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
@@ -108,9 +108,9 @@
 for i in [0, 1]:
     for p, m in testpats[i]:
         if p.startswith(r'^'):
-            p = uprefix + p[1:]
+            p = r"^  \$ (%s)" % p[1:]
         else:
-            p = uprefix + ".*" + p
+            p = r"^  \$ .*(%s)" % p
         utestpats[i].append((p, m))
 
 utestfilters = [