# HG changeset patch # User timeless # Date 1304256150 -7200 # Node ID 82f0412ef7debecd2b26c3ab9b99000cf130bf79 # Parent 4e5a36eeefd1721f66f2d9fc5ac159205e840f36 tests: add pyflakes checking for unused imports diff -r 4e5a36eeefd1 -r 82f0412ef7de tests/filterpyflakes.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/filterpyflakes.py Sun May 01 15:22:30 2011 +0200 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +# Filter output by pyflakes to control which warnings we check + +import sys, re + +for line in sys.stdin: + # We whitelist tests + if not re.search("imported but unused", line): + continue + sys.stdout.write(line) +print diff -r 4e5a36eeefd1 -r 82f0412ef7de tests/hghave --- a/tests/hghave Sun May 01 15:21:57 2011 +0200 +++ b/tests/hghave Sun May 01 15:22:30 2011 +0200 @@ -172,6 +172,11 @@ finally: os.rmdir(d) +def has_pyflakes(): + return matchoutput('echo "import re" 2>&1 | pyflakes', + r":1: 're' imported but unused", + True) + def has_pygments(): try: import pygments @@ -210,6 +215,7 @@ "mtn": (has_mtn, "monotone client (> 0.31)"), "outer-repo": (has_outer_repo, "outer repo"), "p4": (has_p4, "Perforce server and client"), + "pyflakes": (has_pyflakes, "Pyflakes python linter"), "pygments": (has_pygments, "Pygments source highlighting library"), "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"), "svn": (has_svn, "subversion client and admin tools"), diff -r 4e5a36eeefd1 -r 82f0412ef7de tests/test-check-pyflakes.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-check-pyflakes.t Sun May 01 15:22:30 2011 +0200 @@ -0,0 +1,11 @@ + $ "$TESTDIR/hghave" pyflakes || exit 80 + $ cd $(dirname $TESTDIR) + $ pyflakes mercurial hgext 2>&1 | sort | $TESTDIR/filterpyflakes.py + mercurial/commands.py:*: 'base85' imported but unused (glob) + mercurial/commands.py:*: 'bdiff' imported but unused (glob) + mercurial/commands.py:*: 'mpatch' imported but unused (glob) + mercurial/commands.py:*: 'osutil' imported but unused (glob) + mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob) + mercurial/revlog.py:*: 'short' imported but unused (glob) + +