# HG changeset patch # User Simon Heimberg # Date 2013-11-09 09:21:20 # Node ID 22154ec6fb8b7bba40f609b43c89cb00957fc322 # Parent 06e118c097ff108ad62e7d9c5cfeb62bc6f69e0c 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. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -467,6 +467,8 @@ def checkfile(f, logfunc=_defaultlogger. else: p, msg = pat ignore = None + if i >= nerrs: + msg = "warning: " + msg pos = 0 n = 0 @@ -500,8 +502,7 @@ def checkfile(f, logfunc=_defaultlogger. 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 diff --git a/tests/test-check-code.t b/tests/test-check-code.t --- a/tests/test-check-code.t +++ b/tests/test-check-code.t @@ -185,12 +185,20 @@ $ cat > warning.t < $ 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 < raise SomeException, message