[PATCH 1 of 2] check-code: exit status is 0 when only warnings
Simon Heimberg
simohe at besonet.ch
Sat Mar 9 21:22:36 UTC 2013
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1362860793 -3600
# Sat Mar 09 21:26:33 2013 +0100
# Node ID 4b86d47751be828d3f2f3b2a1f30b92340517b35
# Parent 6aca4d1c744ed8f6c1305525ded7590abaa72d06
check-code: exit status is 0 when only warnings
diff -r 6aca4d1c744e -r 4b86d47751be contrib/check-code.py
--- a/contrib/check-code.py Thu Feb 28 10:12:26 2013 -0800
+++ b/contrib/check-code.py Sat Mar 09 21:26:33 2013 +0100
@@ -358,6 +358,7 @@
break
for p, r in filters:
post = re.sub(p, r, post)
+ nerrs = len(pats[0])
if warnings:
pats = pats[0] + pats[1]
else:
@@ -369,7 +370,7 @@
prelines = None
errors = []
- for pat in pats:
+ for i, pat in enumerate(pats):
if len(pat) == 3:
p, msg, ignore = pat
else:
@@ -418,7 +419,8 @@
if bl == l:
bd = '%s@%s' % (bu, br)
errors.append((f, lineno and n + 1, l, msg, bd))
- result = False
+ if i < nerrs:
+ result = False
errors.sort()
for e in errors:
diff -r 6aca4d1c744e -r 4b86d47751be tests/test-check-code-hg.t
--- a/tests/test-check-code-hg.t Thu Feb 28 10:12:26 2013 -0800
+++ b/tests/test-check-code-hg.t Sat Mar 09 21:26:33 2013 +0100
@@ -10,4 +10,4 @@
$ hg manifest 2>/dev/null \
> | xargs "$check_code" --warnings --nolineno --per-file=0 \
- > || false
+ > || echo 'FAILURE IS NOT AN OPTION!!!'
diff -r 6aca4d1c744e -r 4b86d47751be tests/test-check-code.t
--- a/tests/test-check-code.t Thu Feb 28 10:12:26 2013 -0800
+++ b/tests/test-check-code.t Sat Mar 09 21:26:33 2013 +0100
@@ -182,3 +182,12 @@
> raise SomeException, message
don't use old-style two-argument raise, use Exception(message)
[1]
+
+ $ cat > warning.t <<EOF
+ > $ echo \$PWD
+ > EOF
+ $ "$check_code" warning.t
+ $ "$check_code" --warn warning.t
+ warning.t:1:
+ > $ echo $PWD
+ don't use $PWD, use `pwd`
More information about the Mercurial-devel
mailing list