changeset 16672:d046eb97d21e

tests: run most check-code sh checks on continued lines too Some false errors are degraded to warnings and whitelisted.
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 25 Apr 2012 01:35:39 +0200
parents 05b55f5ff8d1
children 775a8d33e6f0
files contrib/check-code.py tests/test-check-code-hg.t
diffstat 2 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Fri May 11 15:09:06 2012 +0200
+++ b/contrib/check-code.py	Wed Apr 25 01:35:39 2012 +0200
@@ -45,12 +45,10 @@
   [
     (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"),
     (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
     (r'echo.*\\n', "don't use 'echo \\n', use printf"),
     (r'echo -n', "don't use 'echo -n', use printf"),
-    (r'^diff.*-\w*N', "don't use 'diff -N'"),
     (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
     (r'head -c', "don't use 'head -c', use 'dd'"),
     (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
@@ -62,10 +60,8 @@
     (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
      "use egrep for extended grep syntax"),
     (r'/bin/', "don't use explicit paths for tools"),
-    (r'\$PWD', "don't use $PWD, use `pwd`"),
     (r'[^\n]\Z', "no trailing newline"),
     (r'export.*=', "don't export and assign at once"),
-    (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
     (r'^source\b', "don't use 'source', use '.'"),
     (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
     (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
@@ -79,7 +75,12 @@
     (r'^( *)\t', "don't use tabs to indent"),
   ],
   # warnings
-  []
+  [
+    (r'^function', "don't use 'function', use old style"),
+    (r'^diff.*-\w*N', "don't use 'diff -N'"),
+    (r'\$PWD', "don't use $PWD, use `pwd`"),
+    (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
+  ]
 ]
 
 testfilters = [
@@ -106,9 +107,9 @@
 for i in [0, 1]:
     for p, m in testpats[i]:
         if p.startswith(r'^'):
-            p = r"^  \$ (%s)" % p[1:]
+            p = r"^  [$>] (%s)" % p[1:]
         else:
-            p = r"^  \$ .*(%s)" % p
+            p = r"^  [$>] .*(%s)" % p
         utestpats[i].append((p, m))
 
 utestfilters = [
--- a/tests/test-check-code-hg.t	Fri May 11 15:09:06 2012 +0200
+++ b/tests/test-check-code-hg.t	Wed Apr 25 01:35:39 2012 +0200
@@ -613,12 +613,25 @@
   tests/test-commandserver.py:0:
    >     print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data))
    warning: line over 80 characters
+  tests/test-convert-mtn.t:0:
+   >   > function get_passphrase(keypair_id)
+   don't use 'function', use old style
   tests/test-filecache.py:0:
    >     except:
    warning: naked except clause
   tests/test-filecache.py:0:
    > if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], 'cacheable']):
    warning: line over 80 characters
+  tests/test-import-git.t:0:
+   >   > Mc\${NkU|\`?^000jF3jhEB
+   ^ must be quoted
+  tests/test-import.t:0:
+   >   > diff -Naur proj-orig/foo proj-new/foo
+   don't use 'diff -N'
+   don't use 'diff -N'
+  tests/test-schemes.t:0:
+   >   > z = file:\$PWD/
+   don't use $PWD, use `pwd`
   tests/test-ui-color.py:0:
    > testui.warn('warning\n')
    warning: unwrapped ui message