check-code: prepend warning prefix only once, but for each warning stable
authorSimon Heimberg <simohe@besonet.ch>
Sat, 09 Nov 2013 10:21:20 +0100
branchstable
changeset 20005 22154ec6fb8b
parent 20004 06e118c097ff
child 20009 2802bedbd45f
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.
contrib/check-code.py
tests/test-check-code.t
--- 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