Mercurial > hg
changeset 12364:e128fa4615f2
check-code: add some basic support for unified tests
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 21 Sep 2010 12:41:24 -0500 |
parents | 8a5b6383ba02 |
children | 22f3353bcc36 |
files | contrib/check-code.py |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Tue Sep 21 23:58:32 2010 +0200 +++ b/contrib/check-code.py Tue Sep 21 12:41:24 2010 -0500 @@ -70,6 +70,26 @@ (r"<<(\S+)((.|\n)*?\n\1)", rephere), ] +uprefix = r"^ \$ " +utestpats = [ + (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"), + (uprefix + r'.*\$\?', "explicit exit code checks unnecessary"), + (uprefix + r'.*\|\| echo.*(fail|error)', + "explicit exit code checks unnecessary"), + (uprefix + r'set -e', "don't use set -e"), +] + +for p, m in testpats: + if p.startswith('^'): + p = uprefix + p[1:] + else: + p = uprefix + p + utestpats.append((p, m)) + +utestfilters = [ + (r"( *)(#([^\n]*\S)?)", repcomment), +] + pypats = [ (r'^\s*def\s*\w+\s*\(.*,\s*\(', "tuple parameter unpacking not available in Python 3+"), @@ -157,6 +177,7 @@ ('python', r'.*\.(py|cgi)$', pyfilters, pypats), ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats), ('c', r'.*\.c$', cfilters, cpats), + ('unified test', r'.*\.t$', utestfilters, utestpats), ] class norepeatlogger(object):