tests/filterpyflakes.py
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
Thu, 05 May 2011 12:53:33 +0200
changeset 14199 e3dd3dcd6059
parent 14176 dea68bddfb87
child 14209 08d84bdce1a5
permissions -rwxr-xr-x
treediscovery: fix regression when run against older repos (issue2793) I ran the entire test suite with "known" and "getbundle" disabled in localrepository. This generated failures because the old findoutgoing had always queried remote's heads explicitly and thus always got them back in the returned heads. treediscovery.findcommonincoming now correctly returns remote's heads in all cases. Also adds a dedicated test for running treediscovery against a pre-getbundle HTTP server.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     1
#!/usr/bin/env python
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     2
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     3
# Filter output by pyflakes to control which warnings we check
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     4
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     5
import sys, re
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
     6
14173
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
     7
def makekey(message):
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
     8
    # "path/file:line: message"
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
     9
    match = re.search(r"(line \d+)", message)
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    10
    line = ''
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    11
    if match:
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    12
        line = match.group(0)
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    13
        message = re.sub(r"(line \d+)", '', message)
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    14
    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    15
                  r'\3:\5:\4:\1:\2:' + line,
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    16
                  message)
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    17
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    18
lines = []
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
    19
for line in sys.stdin:
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
    20
    # We whitelist tests
14175
b452abffcb15 tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents: 14173
diff changeset
    21
    pats = [
b452abffcb15 tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents: 14173
diff changeset
    22
            r"imported but unused",
b452abffcb15 tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents: 14173
diff changeset
    23
            r"local variable '.*' is assigned to but never used",
14176
dea68bddfb87 test: add pyflakes checking for unable to detect undefined names
timeless <timeless@mozdev.org>
parents: 14175
diff changeset
    24
            r"unable to detect undefined names",
14175
b452abffcb15 tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents: 14173
diff changeset
    25
           ]
b452abffcb15 tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents: 14173
diff changeset
    26
    if not re.search('|'.join(pats), line):
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
    27
        continue
14173
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    28
    lines.append(line)
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    29
419539ea79cb test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents: 14140
diff changeset
    30
for line in sorted(lines, key = makekey):
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
    31
    sys.stdout.write(line)
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff changeset
    32
print