##// END OF EJS Templates
filterpyflakes: move self-test into test file...
Augie Fackler -
r33367:6029939f default
parent child Browse files
Show More
@@ -1,41 +1,37 b''
1 1 #!/usr/bin/env python
2 2
3 3 # Filter output by pyflakes to control which warnings we check
4 4
5 5 from __future__ import absolute_import, print_function
6 6
7 7 import re
8 8 import sys
9 9
10 10 lines = []
11 11 for line in sys.stdin:
12 12 # We blacklist tests that are too noisy for us
13 13 pats = [
14 14 r"undefined name 'WindowsError'",
15 15 r"redefinition of unused '[^']+' from line",
16 16 # for cffi, allow re-exports from pure.*
17 17 r"cffi/[^:]*:.*\bimport \*' used",
18 18 r"cffi/[^:]*:.*\*' imported but unused",
19 19 ]
20 20
21 21 keep = True
22 22 for pat in pats:
23 23 if re.search(pat, line):
24 24 keep = False
25 25 break # pattern matches
26 26 if keep:
27 27 fn = line.split(':', 1)[0]
28 28 f = open(fn)
29 29 data = f.read()
30 30 f.close()
31 31 if 'no-' 'check-code' in data:
32 32 continue
33 33 lines.append(line)
34 34
35 35 for line in lines:
36 36 sys.stdout.write(line)
37 37 print()
38
39 # self test of "undefined name" detection
40 if False:
41 print(undefinedname)
@@ -1,15 +1,21 b''
1 1 #require test-repo pyflakes hg10
2 2
3 3 $ . "$TESTDIR/helpers-testrepo.sh"
4 4 $ cd "`dirname "$TESTDIR"`"
5 5
6 6 run pyflakes on all tracked files ending in .py or without a file ending
7 7 (skipping binary file random-seed)
8 8
9 $ cat > test.py <<EOF
10 > print(undefinedname)
11 > EOF
12 $ pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
13 test.py:1: undefined name 'undefinedname'
14
15
9 16 $ testrepohg locate 'set:**.py or grep("^#!.*python")' \
10 17 > -X hgext/fsmonitor/pywatchman \
11 18 > -X mercurial/pycompat.py -X contrib/python-zstandard \
12 19 > 2>/dev/null \
13 20 > | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
14 tests/filterpyflakes.py:41: undefined name 'undefinedname'
15 21
General Comments 0
You need to be logged in to leave comments. Login now