Patchwork [3,of,4] test-pyflakes: detect undefined name error

login
register
mail settings
Submitter Yuya Nishihara
Date May 2, 2014, 4:28 a.m.
Message ID <ce23921fe33159c5ddec.1399004939@gimlet>
Download mbox | patch
Permalink /patch/4484/
State Superseded
Commit 0768cda8b5799dc803dc0ee27a832cd64e05f28a
Headers show

Comments

Yuya Nishihara - May 2, 2014, 4:28 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1398743641 -32400
#      Tue Apr 29 12:54:01 2014 +0900
# Branch stable
# Node ID ce23921fe33159c5ddec89474ae4a01caf301481
# Parent  9428e9853f59843545eac04caf8463ebf1d5efa2
test-pyflakes: detect undefined name error

It should be able to catch the following mistakes at 2606e7f227f6:

    mercurial/exchange.py:590: undefined name 'UnknownPartError'
    mercurial/match.py:346: undefined name 'pat'
    mercurial/win32.py:365: undefined name '_ERROR_NO_MORE_FILES'
    tests/killdaemons.py:46: undefined name 'check'

Still it includes false-positive detection of global variables defined in
function, that should be addressed by the next patch.

Patch

diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
--- a/tests/filterpyflakes.py
+++ b/tests/filterpyflakes.py
@@ -32,6 +32,7 @@  for line in sys.stdin:
             r"imported but unused",
             r"local variable '.*' is assigned to but never used",
             r"unable to detect undefined names",
+            r"undefined name '.*'",
            ]
     for msgtype, pat in enumerate(pats):
         if re.search(pat, line):
diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
--- a/tests/test-check-pyflakes.t
+++ b/tests/test-check-pyflakes.t
@@ -16,5 +16,35 @@  run pyflakes on all tracked python scrip
   tests/hghave.py:*: 'pygments' imported but unused (glob)
   tests/hghave.py:*: 'ssl' imported but unused (glob)
   contrib/win32/hgwebdir_wsgi.py:93: 'from isapi.install import *' used; unable to detect undefined names (glob)
+  hgext/factotum.py:61: undefined name '_executable'
+  hgext/factotum.py:66: undefined name '_mountpoint'
+  hgext/factotum.py:105: undefined name '_service'
+  tests/run-tests.py:426: undefined name 'HGTMP'
+  tests/run-tests.py:427: undefined name 'HGTMP'
+  tests/run-tests.py:441: undefined name 'TMPBINDIR'
+  tests/run-tests.py:495: undefined name 'HGTMP'
+  tests/run-tests.py:496: undefined name 'BINDIR'
+  tests/run-tests.py:496: undefined name 'INST'
+  tests/run-tests.py:496: undefined name 'PYTHONDIR'
+  tests/run-tests.py:508: undefined name 'TESTDIR'
+  tests/run-tests.py:514: undefined name 'BINDIR'
+  tests/run-tests.py:518: undefined name 'BINDIR'
+  tests/run-tests.py:523: undefined name 'BINDIR'
+  tests/run-tests.py:540: undefined name 'TESTDIR'
+  tests/run-tests.py:541: undefined name 'PYTHONDIR'
+  tests/run-tests.py:544: undefined name 'TESTDIR'
+  tests/run-tests.py:547: undefined name 'INST'
+  tests/run-tests.py:561: undefined name 'PYTHONDIR'
+  tests/run-tests.py:569: undefined name 'BINDIR'
+  tests/run-tests.py:569: undefined name 'TESTDIR'
+  tests/run-tests.py:572: undefined name 'TESTDIR'
+  tests/run-tests.py:575: undefined name 'TESTDIR'
+  tests/run-tests.py:679: undefined name 'TESTDIR'
+  tests/run-tests.py:927: undefined name 'TESTDIR'
+  tests/run-tests.py:928: undefined name 'TESTDIR'
+  tests/run-tests.py:956: undefined name 'TESTDIR'
+  tests/run-tests.py:967: undefined name 'HGTMP'
+  tests/run-tests.py:1090: undefined name 'PYTHONDIR'
+  tests/run-tests.py:1142: undefined name 'INST'
   
 #endif