[PATCH 2 of 4] test-pyflakes: do not parse file that is unlikely a Python script

Yuya Nishihara yuya at tcha.org
Thu May 1 23:28:58 CDT 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1398743365 -32400
#      Tue Apr 29 12:49:25 2014 +0900
# Branch stable
# Node ID 9428e9853f59843545eac04caf8463ebf1d5efa2
# Parent  ab91be7bb1a363e7ff320bece1e238dcf8d634e1
test-pyflakes: do not parse file that is unlikely a Python script

This eliminates false alarm triggered by parsing shell scripts or template
map files.  For example, "pyflakes mercurial/templates/atom/map" reports
many "undefined name"s.

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
@@ -2,10 +2,9 @@
 
   $ cd "`dirname "$TESTDIR"`"
 
-run pyflakes on all tracked files ending in .py or without a file ending
-(skipping binary file random-seed)
+run pyflakes on all tracked python scripts
 
-  $ hg locate -r. -I '**.py' -I 'relre:^[^.]*$' -X 'relre:/random_seed$' \
+  $ hg locate -r. -I '**.py' -I 'set: "relre:^[^.]*$" and grep("^#!.*python")' \
   > 2>/dev/null | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
   contrib/win32/hgwebdir_wsgi.py:*: 'win32traceutil' imported but unused (glob)
   setup.py:*: 'sha' imported but unused (glob)


More information about the Mercurial-devel mailing list