changeset 16495:5f9835ed3d6d stable

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.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 23 Apr 2012 01:56:48 +0200
parents e1f0305eabe4
children abbabbbe4ec2
files contrib/check-code.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 = [