Commit Graph

36 Commits

Author SHA1 Message Date
Jun Wu
6fb604b0fb test-check-pyflakes: do not leave test.py in the repo
Differential Revision: https://phab.mercurial-scm.org/D67
2017-07-12 15:27:56 -07:00
Augie Fackler
22265cfcba filterpyflakes: move self-test into test file
This will avoid a false positive on an upcoming check-code rule.

Differential Revision: https://phab.mercurial-scm.org/D18
2017-07-07 15:07:36 -04:00
Yuya Nishihara
8f3fa790c1 tests: alias syshg and syshgenv so they can be switched conditionally 2017-07-02 13:14:20 +09:00
Adam Simpkins
55a457de69 tests: use the system hg for examining the local repository
Most test scripts use "hg" to interact with a temporary test repository.
However a few tests also want to run hg commands to interact with the local
repository containing the mercurial source code.  Notably, many of the
test-check-* tests want to check local files and commit messages.

These tests were previously using the version of hg being tested to query the
source repository.  However, this will fail if the source repository requires
extensions or other settings not supported by the version of mercurial being
tested.  The source repository was typically initially cloned using the system
hg installation, so we should use the system hg installation to query it.

There was already a helpers-testrepo.sh script designed to help cope with
different requirements for the source repository versus the test repositories.
However, it only handled the evolve extension.  This new behavior works with
any extensions that are different between the system installation and the test
installation.
2017-06-27 17:24:31 -07:00
Yuya Nishihara
cde823009a filterpyflakes: allow reexporting pure symbols from cffi modules
cffi modules will do 'from ..pure.<module> import *'.
2017-05-28 17:36:01 +09:00
Gregory Szorc
5d323ec3c4 tests: remove special handling for undefined memoryview
'memoryview' was introduced in Python 2.7. 73ce96f78032 added code
to filterpyflakes.py to ignore "undefined name 'memoryview'" pyflakes
warnings. Since we no longer support <Python 2.7, we can remove this
workaround.
2017-05-13 11:31:36 -07:00
Augie Fackler
96d33e9cdd tests: exclude python-zstandard from pyflakes analysis 2017-02-09 21:44:32 -05:00
Zack Hricz
aa812e5c73 tests: exclude bundled pywatchman from test-check-pyflakes
The code under pywatchman used to be excluded from test-check-code and
test-check-pyflakes through the magic string "no-check-code". Now that
test-check-code excludes the pywatchman directory entirely, the directory
should also be excluded from test-check-pyflakes.
2016-12-22 11:07:59 -08:00
Gregory Szorc
2005375cdc zstd: vendor python-zstandard 0.5.0
As the commit message for the previous changeset says, we wish
for zstd to be a 1st class citizen in Mercurial. To make that
happen, we need to enable Python to talk to the zstd C API. And
that requires bindings.

This commit vendors a copy of existing Python bindings. Why do we
need to vendor? As the commit message of the previous commit says,
relying on systems in the wild to have the bindings or zstd present
is a losing proposition. By distributing the zstd and bindings with
Mercurial, we significantly increase our chances that zstd will
work. Since zstd will deliver a better end-user experience by
achieving better performance, this benefits our users. Another
reason is that the Python bindings still aren't stable and the
API is somewhat fluid. While Mercurial could be coded to target
multiple versions of the Python bindings, it is safer to bundle
an explicit, known working version.

The added Python bindings are mostly a fully-featured interface
to the zstd C API. They allow one-shot operations, streaming,
reading and writing from objects implements the file object
protocol, dictionary compression, control over low-level compression
parameters, and more. The Python bindings work on Python 2.6,
2.7, and 3.3+ and have been tested on Linux and Windows. There are
CFFI bindings, but they are lacking compared to the C extension.
Upstream work will be needed before we can support zstd with PyPy.
But it will be possible.

The files added in this commit come from Git commit
e637c1b214d5f869cf8116c550dcae23ec13b677 from
https://github.com/indygreg/python-zstandard and are added without
modifications. Some files from the upstream repository have been
omitted, namely files related to continuous integration.

In the spirit of full disclosure, I'm the maintainer of the
"python-zstandard" project and have authored 100% of the code
added in this commit. Unfortunately, the Python bindings have
not been formally code reviewed by anyone. While I've tested
much of the code thoroughly (I even have tests that fuzz APIs),
there's a good chance there are bugs, memory leaks, not well
thought out APIs, etc. If someone wants to review the code and
send feedback to the GitHub project, it would be greatly
appreciated.

Despite my involvement with both projects, my opinions of code
style differ from Mercurial's. The code in this commit introduces
numerous code style violations in Mercurial's linters. So, the code
is excluded from most lints. However, some violations I agree with.
These have been added to the known violations ignore list for now.
2016-11-10 22:15:58 -08:00
Augie Fackler
0058294764 filterpyflakes: dramatically simplify the entire thing by blacklisting
We've only got one kind of pyflakes failure left in our codebase, so
it's time to switch over to a blacklist-based checking scheme. I've
left in the filtering of two undefined names for now out of paranoia,
but those can probably go too.
2016-11-10 16:49:42 -05:00
Augie Fackler
2382566005 filterpyflakes: whitelist listcomp aliasing checking
The test change is because of how filterpyflakes is organized - a line
number changed.
2016-11-10 16:37:18 -05:00
Pulkit Goyal
c87a2b01ec pycompat: make pycompat demandimport friendly
pycompat.py includes hack to import modules whose names are changed in Python 3.
We use try-except to load module according to the version of python. But this
method forces us to import the modules to raise an ImportError and hence making
it demandimport unfriendly.

This patch changes the try-except blocks to a single if-else block. To avoid
test-check-pyflakes.t complain about unused imports, pycompat.py is excluded
from the test.
2016-07-17 19:48:04 +05:30
Yuya Nishihara
f979d1d5bd tests: fix typo of shebang prefix in test-check-pyflakes.t 2016-05-15 10:41:01 +09:00
timeless
0c82fc02cd tests: silence test-repo obsolete warning
refactoring test-check-commit.t HGRCPATH bits as helpers-testrepo.sh
2016-05-11 04:49:27 +00:00
timeless
9978c7c07e tests: mark test-check-pyflakes.t as requiring hg1.0+
hg does not yet run with py3, so if you try:
./run-tests.py --local test-check-pyflakes.t

... it will try to run the local hg, which does not work
and thus, hg locate will return no output to stdout (and
stderr is sent to /dev/null).

If you do:
./run-tests.py --with-hg=~/bin/hg test-check-pyflakes.t
Then it should work, if your hg is new enough to have
a locate command (hg0.6 does not have locate).
2016-05-05 09:26:09 +00:00
Gregory Szorc
eeefc7c496 tests/filterpyflakes: use absolute_import 2015-12-06 22:22:09 -08:00
Mads Kiilerich
5d1360e0ed cleanup: make sure we always access members of imported modules
This will make sure we get import errors, even if demandimport is enabled.

This will also mute some pyflakes 'imported but unused' warnings.
2014-08-15 04:37:45 +02:00
Matt Mackall
a2b42e253a tests: fix pyflakes test whitespace breakage 2014-08-06 12:16:58 -05:00
Matt Mackall
241d2dc08e tests: change some #ifs to #requires 2014-08-06 11:53:08 -05:00
Matt Mackall
88809bfcbd filterpyflakes: make memoryview filtering unconditional 2014-05-13 19:22:40 -05:00
FUJIWARA Katsunori
6750e4199f tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
Before this patch, "test-check-pyflakes.t" shows unexpected "undefined
name 'memoryview'" error for "mercurial/util.py" on Python 2.6.x or
earlier, because they don't define symbol 'memoryview'.

This patch introduces excluding patterns into "filterpyflakes.py" to
ignore "undefined name 'memoryview'" pyflakes error on Python 2.6.x or
earlier
2014-05-09 08:44:53 +09:00
Matt Mackall
bceb50a9b8 tests: use locate to find files for pyflakes check
Based on a suggestion by Yuya Nishihara
2014-05-02 00:23:58 -05:00
Matt Mackall
36234f5a00 tests: add repository check for pyflakes test
If this test was run from a tarball with no Mercurial repository, it
would fail because 'hg manifest' didn't work.
2014-05-01 09:42:23 -05:00
Matt Mackall
eb09e501b5 tests: fix unused imports from inotify removal caught by pyflakes 2014-03-04 09:56:59 -06:00
Matt Mackall
66c8bd54e8 extensions: remove the inotify extension (BC)
This extension has always had correctness issues and has been
unmaintained for years. It is now removed in favor of the third-party
hgwatchman which is maintained and appears to be correct.

Users with inotify enabled in their config files will fall back to
standard status performance.
2014-03-01 16:20:15 -06:00
Simon Heimberg
6059e06d0f cleanup: drop unused variables and an unused import 2013-07-01 20:48:56 +02:00
Simon Heimberg
752411a141 tests: run pyflakes on files from manifest which could be python files
Skip a binary file because pyflakes 0.4.0 aborts on it.
2013-07-01 20:48:55 +02:00
Thomas Arendsen Hein
21bb7c4cdc tests: make tests work if directory contains special characters
With this quoting tests will work e.g. in "/tmp/foo bar/mercurial/".
2012-04-03 19:06:35 +02:00
Matt Mackall
8971e5af3c check-code: fix issues with finding patterns in unified tests, fix tests
- old-style patterns without ^ were getting improperly anchored
- finditer was matching against beginning of line poorly
- \s was matching newlines
- [^x] was matching newlines

so we:

- remove earlier hacks for multiline matching
- fix unified test anchoring by adding .*
- replace \s with [ \t]
- replace [^x] with [^\nx]
- force all matches into multiline mode so ^ anchors work

This uncovers a number of test issues that are then repaired.
2011-10-27 17:22:04 -05:00
Matt Mackall
944b7f7b5c pyflakes: clean up some import noise 2011-10-11 23:16:05 -05:00
Adrian Buehlmann
b58d26815b windows: eliminate win32 wildcard import 2011-07-29 00:39:27 +02:00
Adrian Buehlmann
f1218befa0 util: eliminate wildcard imports 2011-07-23 12:29:52 +02:00
Matt Mackall
66805ccfed revlog: stop exporting node.short 2011-05-21 15:01:28 -05:00
timeless
1760e54c82 test: add pyflakes checking for unable to detect undefined names 2011-05-01 17:36:16 +02:00
timeless
1e24d74cfd test-pyflake: improve sorting algorithm 2011-05-01 18:56:27 +02:00
timeless
75e43f8a4b tests: add pyflakes checking for unused imports 2011-05-01 15:22:30 +02:00