# HG changeset patch # User Mads Kiilerich # Date 2012-04-24 23:35:39 # Node ID d046eb97d21e6927374bbc7bc3387bad49896cf9 # Parent 05b55f5ff8d1c65a3934cbb7b6aa736638fa1c52 tests: run most check-code sh checks on continued lines too Some false errors are degraded to warnings and whitelisted. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -45,12 +45,10 @@ testpats = [ [ (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 @@ testpats = [ (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 @@ testpats = [ (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 @@ utestpats = [ 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 = [ diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t --- a/tests/test-check-code-hg.t +++ b/tests/test-check-code-hg.t @@ -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