test-pyflake: improve sorting algorithm
authortimeless <timeless@mozdev.org>
Sun, 01 May 2011 18:56:27 +0200
changeset 14173 419539ea79cb
parent 14172 1a919c3271bf
child 14174 bab267e7fc1a
test-pyflake: improve sorting algorithm
tests/filterpyflakes.py
tests/test-check-pyflakes.t
--- a/tests/filterpyflakes.py	Mon May 02 09:50:21 2011 +0200
+++ b/tests/filterpyflakes.py	Sun May 01 18:56:27 2011 +0200
@@ -4,9 +4,24 @@
 
 import sys, re
 
+def makekey(message):
+    # "path/file:line: message"
+    match = re.search(r"(line \d+)", message)
+    line = ''
+    if match:
+        line = match.group(0)
+        message = re.sub(r"(line \d+)", '', message)
+    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
+                  r'\3:\5:\4:\1:\2:' + line,
+                  message)
+
+lines = []
 for line in sys.stdin:
     # We whitelist tests
     if not re.search("imported but unused", line):
         continue
+    lines.append(line)
+
+for line in sorted(lines, key = makekey):
     sys.stdout.write(line)
 print
--- a/tests/test-check-pyflakes.t	Mon May 02 09:50:21 2011 +0200
+++ b/tests/test-check-pyflakes.t	Sun May 01 18:56:27 2011 +0200
@@ -1,11 +1,11 @@
   $ "$TESTDIR/hghave" pyflakes || exit 80
   $ cd $(dirname $TESTDIR)
-  $ pyflakes mercurial hgext 2>&1 | sort | $TESTDIR/filterpyflakes.py
+  $ pyflakes mercurial hgext 2>&1 | $TESTDIR/filterpyflakes.py
+  mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob)
   mercurial/commands.py:*: 'base85' imported but unused (glob)
   mercurial/commands.py:*: 'bdiff' imported but unused (glob)
   mercurial/commands.py:*: 'mpatch' imported but unused (glob)
   mercurial/commands.py:*: 'osutil' imported but unused (glob)
-  mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob)
   mercurial/revlog.py:*: 'short' imported but unused (glob)