Patchwork [1,of,2] check-code: exit status is 0 when only warnings

login
register
mail settings
Submitter Simon Heimberg
Date March 9, 2013, 9:22 p.m.
Message ID <4b86d47751be828d3f2f.1362864156@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1098/
State Changes Requested
Headers show

Comments

Simon Heimberg - March 9, 2013, 9:22 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@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
Bryan O'Sullivan - March 27, 2013, 3:46 p.m.
On Sat, Mar 9, 2013 at 1:22 PM, Simon Heimberg <simohe@besonet.ch> wrote:

> check-code: exit status is 0 when only warnings
>

I have no idea what this means, or how it relates to whatever the changes
in the patch are trying to do (which I also don't understand).
Matt Mackall - April 17, 2013, 7:50 p.m.
On Sat, 2013-03-09 at 22:22 +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@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

Not sure why this is wanted? Going to drop until an explanation appears.

Patch

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`