Mercurial > hg
annotate tests/filterpyflakes.py @ 23976:344939126579 stable
largefiles: don't interfere with logging normal files
The previous code was adding standin files to the matcher's file list when
neither the standin file nor the original existed in the context. Somehow, this
was confusing the logging code into behaving differently from when the extension
wasn't loaded.
It seems that this was an attempt to support naming a directory that only
contains largefiles, as a test fails if the else clause is dropped entirely.
Therefore, only append the "standin" if it is a directory. This was found by
running the test suite with --config extensions.largefiles=.
The first added test used to log an additional cset that wasn't logged normally.
The only relation it had to file 'a' is that 'a' was the source of a move, but
it isn't clear why having '.hglf/a' in the list causes this change:
@@ -47,6 +47,11 @@
Make sure largefiles doesn't interfere with logging a regular file
$ hg log a --config extensions.largefiles=
+ changeset: 3:2ca5ba701980
+ user: test
+ date: Thu Jan 01 00:00:04 1970 +0000
+ summary: d
+
changeset: 0:9161b9aeaf16
user: test
date: Thu Jan 01 00:00:01 1970 +0000
The second added test used to complain about a file not being in the parent
revision:
@@ -1638,10 +1643,8 @@
Ensure that largefiles doesn't intefere with following a normal file
$ hg --config extensions.largefiles= log -f d -T '{desc}' -G
- @ c
- |
- o a
-
+ abort: cannot follow file not in parent revision: ".hglf/d"
+ [255]
$ hg log -f d/a -T '{desc}' -G
@ c
|
Note that there is still something fishy with the largefiles code, because when
using a glob pattern like this:
$ hg log 'glob:sub/*'
the pattern list would contain '.hglf/glob:sub/*'. None of the tests show this
(this test lives in test-largefiles.t at 1349), it was just something that I
noticed when the code was loaded up with print statements.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 30 Jan 2015 20:44:11 -0500 |
parents | 1ae3cd6f836c |
children | 48671378daeb |
rev | line source |
---|---|
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 |
14209
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
5 import sys, re, os |
14140
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
6 |
19335
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
7 def makekey(typeandline): |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
8 """ |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
9 for sorting lines by: msgtype, path/to/file, lineno, message |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
10 |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
11 typeandline is a sequence of a message type and the entire message line |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
12 the message line format is path/to/file:line: message |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
13 |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
14 >>> makekey((3, 'example.py:36: any message')) |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
15 (3, 'example.py', 36, ' any message') |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
16 >>> makekey((7, 'path/to/file.py:68: dummy message')) |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
17 (7, 'path/to/file.py', 68, ' dummy message') |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
18 >>> makekey((2, 'fn:88: m')) > makekey((2, 'fn:9: m')) |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
19 True |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
20 """ |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
21 |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
22 msgtype, line = typeandline |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
23 fname, line, message = line.split(":", 2) |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
24 # line as int for ordering 9 before 88 |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
25 return msgtype, fname, int(line), message |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
26 |
14173
419539ea79cb
test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents:
14140
diff
changeset
|
27 |
419539ea79cb
test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents:
14140
diff
changeset
|
28 lines = [] |
14140
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
29 for line in sys.stdin: |
19335
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
30 # We whitelist tests (see more messages in pyflakes.messages) |
14175
b452abffcb15
tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents:
14173
diff
changeset
|
31 pats = [ |
21271
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
32 (r"imported but unused", None), |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
33 (r"local variable '.*' is assigned to but never used", None), |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
34 (r"unable to detect undefined names", None), |
21293
507ce509fd22
filterpyflakes: make memoryview filtering unconditional
Matt Mackall <mpm@selenic.com>
parents:
21271
diff
changeset
|
35 (r"undefined name '.*'", |
21294
1ae3cd6f836c
filterpyflakes: filter WindowsError unconditionally
Matt Mackall <mpm@selenic.com>
parents:
21293
diff
changeset
|
36 r"undefined name '(WindowsError|memoryview)'") |
14175
b452abffcb15
tests: add pyflakes checking for assigned to but never used
timeless <timeless@mozdev.org>
parents:
14173
diff
changeset
|
37 ] |
21293
507ce509fd22
filterpyflakes: make memoryview filtering unconditional
Matt Mackall <mpm@selenic.com>
parents:
21271
diff
changeset
|
38 |
21271
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
39 for msgtype, (pat, excl) in enumerate(pats): |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
40 if re.search(pat, line) and (not excl or not re.search(excl, line)): |
19335
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
41 break # pattern matches |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
42 else: |
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
43 continue # no pattern matched, next line |
14209
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
44 fn = line.split(':', 1)[0] |
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
45 f = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), fn)) |
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
46 data = f.read() |
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
47 f.close() |
19381
e033a7d444ac
tests: do not skip code-checking on some whole files
Simon Heimberg <simohe@besonet.ch>
parents:
19335
diff
changeset
|
48 if 'no-' 'check-code' in data: |
14209
08d84bdce1a5
pyflakes: ignore files marked no-check-code
Augie Fackler <durin42@gmail.com>
parents:
14176
diff
changeset
|
49 continue |
19335
77440de177f7
tests: simplify and document the sorting of pyflake messages
Simon Heimberg <simohe@besonet.ch>
parents:
14209
diff
changeset
|
50 lines.append((msgtype, line)) |
14173
419539ea79cb
test-pyflake: improve sorting algorithm
timeless <timeless@mozdev.org>
parents:
14140
diff
changeset
|
51 |
19872
681f7b9213a4
check-code: check for spaces around = for named parameters
Mads Kiilerich <madski@unity3d.com>
parents:
19381
diff
changeset
|
52 for msgtype, line in sorted(lines, key=makekey): |
14140
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
53 sys.stdout.write(line) |
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
54 print |
21271
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
55 |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
56 # self test of "undefined name" detection for other than 'memoryview' |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
57 if False: |
4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21232
diff
changeset
|
58 print undefinedname |