changeset 20005:22154ec6fb8b stable

check-code: prepend warning prefix only once, but for each warning The code adding the prefix is now run once per pattern. It was run once per file (after the change 3e1e4a8aec1e). Demonstrate that it is working now by extending the test. Raise two different warnings, one of them twice.
author Simon Heimberg <simohe@besonet.ch>
date Sat, 09 Nov 2013 10:21:20 +0100
parents 06e118c097ff
children 2802bedbd45f
files contrib/check-code.py tests/test-check-code.t
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Wed Nov 13 16:46:46 2013 -0200
+++ b/contrib/check-code.py	Sat Nov 09 10:21:20 2013 +0100
@@ -467,6 +467,8 @@
             else:
                 p, msg = pat
                 ignore = None
+            if i >= nerrs:
+                msg = "warning: " + msg
 
             pos = 0
             n = 0
@@ -500,8 +502,7 @@
                         bl, bu, br = blamecache[n]
                         if bl == l:
                             bd = '%s@%s' % (bu, br)
-                if i >= nerrs:
-                    msg = "warning: " + msg
+
                 errors.append((f, lineno and n + 1, l, msg, bd))
                 result = False
 
--- a/tests/test-check-code.t	Wed Nov 13 16:46:46 2013 -0200
+++ b/tests/test-check-code.t	Sat Nov 09 10:21:20 2013 +0100
@@ -185,12 +185,20 @@
   $ cat > warning.t <<EOF
   >   $ function warnonly {
   >   > }
+  >   $ diff -N aaa
+  >   $ function onwarn {}
   > EOF
   $ "$check_code" warning.t
   $ "$check_code" --warn warning.t
   warning.t:1:
    >   $ function warnonly {
    warning: don't use 'function', use old style
+  warning.t:3:
+   >   $ diff -N aaa
+   warning: don't use 'diff -N'
+  warning.t:4:
+   >   $ function onwarn {}
+   warning: don't use 'function', use old style
   [1]
   $ cat > raise-format.py <<EOF
   > raise SomeException, message