##// END OF EJS Templates
test: add pyflakes checking for unable to detect undefined names
timeless -
r14176:dea68bdd default
parent child Browse files
Show More
@@ -1,31 +1,32 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2
2
3 # Filter output by pyflakes to control which warnings we check
3 # Filter output by pyflakes to control which warnings we check
4
4
5 import sys, re
5 import sys, re
6
6
7 def makekey(message):
7 def makekey(message):
8 # "path/file:line: message"
8 # "path/file:line: message"
9 match = re.search(r"(line \d+)", message)
9 match = re.search(r"(line \d+)", message)
10 line = ''
10 line = ''
11 if match:
11 if match:
12 line = match.group(0)
12 line = match.group(0)
13 message = re.sub(r"(line \d+)", '', message)
13 message = re.sub(r"(line \d+)", '', message)
14 return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
14 return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
15 r'\3:\5:\4:\1:\2:' + line,
15 r'\3:\5:\4:\1:\2:' + line,
16 message)
16 message)
17
17
18 lines = []
18 lines = []
19 for line in sys.stdin:
19 for line in sys.stdin:
20 # We whitelist tests
20 # We whitelist tests
21 pats = [
21 pats = [
22 r"imported but unused",
22 r"imported but unused",
23 r"local variable '.*' is assigned to but never used",
23 r"local variable '.*' is assigned to but never used",
24 r"unable to detect undefined names",
24 ]
25 ]
25 if not re.search('|'.join(pats), line):
26 if not re.search('|'.join(pats), line):
26 continue
27 continue
27 lines.append(line)
28 lines.append(line)
28
29
29 for line in sorted(lines, key = makekey):
30 for line in sorted(lines, key = makekey):
30 sys.stdout.write(line)
31 sys.stdout.write(line)
31 print
32 print
@@ -1,11 +1,15 b''
1 $ "$TESTDIR/hghave" pyflakes || exit 80
1 $ "$TESTDIR/hghave" pyflakes || exit 80
2 $ cd $(dirname $TESTDIR)
2 $ cd $(dirname $TESTDIR)
3 $ pyflakes mercurial hgext 2>&1 | $TESTDIR/filterpyflakes.py
3 $ pyflakes mercurial hgext 2>&1 | $TESTDIR/filterpyflakes.py
4 mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob)
4 mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob)
5 mercurial/commands.py:*: 'base85' imported but unused (glob)
5 mercurial/commands.py:*: 'base85' imported but unused (glob)
6 mercurial/commands.py:*: 'bdiff' imported but unused (glob)
6 mercurial/commands.py:*: 'bdiff' imported but unused (glob)
7 mercurial/commands.py:*: 'mpatch' imported but unused (glob)
7 mercurial/commands.py:*: 'mpatch' imported but unused (glob)
8 mercurial/commands.py:*: 'osutil' imported but unused (glob)
8 mercurial/commands.py:*: 'osutil' imported but unused (glob)
9 mercurial/revlog.py:*: 'short' imported but unused (glob)
9 mercurial/revlog.py:*: 'short' imported but unused (glob)
10 hgext/inotify/linux/__init__.py:*: 'from _inotify import *' used; unable to detect undefined names (glob)
11 mercurial/util.py:*: 'from posix import *' used; unable to detect undefined names (glob)
12 mercurial/windows.py:*: 'from win32 import *' used; unable to detect undefined names (glob)
13 mercurial/util.py:*: 'from windows import *' used; unable to detect undefined names (glob)
10
14
11
15
General Comments 0
You need to be logged in to leave comments. Login now