annotate tests/test-doctest.py @ 30435:b86a448a2965

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 10 Nov 2016 22:15:58 -0800
parents 6262f0215d08
children 783016005122
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7041
b856071435f7 tests: fix readline escape characters in output for test-doctest.py
Mads Kiilerich <mads@kiilerich.com>
parents: 5525
diff changeset
1 # this is hack to make sure no escape characters are inserted into the output
28933
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
2
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
3 from __future__ import absolute_import
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
4
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
5 import doctest
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
6 import os
6262f0215d08 tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 27432
diff changeset
7 import sys
7078
967adcf5910d test-doctest: remove TERM env variable only if it's there
Patrick Mezard <pmezard@gmail.com>
parents: 7041
diff changeset
8 if 'TERM' in os.environ:
7184
380fda3eed13 clean up trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7078
diff changeset
9 del os.environ['TERM']
3232
394ac87f3b74 [extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
10
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
11 def testmod(name, optionflags=0, testtarget=None):
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
12 __import__(name)
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
13 mod = sys.modules[name]
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
14 if testtarget is not None:
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
15 mod = getattr(mod, testtarget)
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
16 doctest.testmod(mod, optionflags=optionflags)
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 13949
diff changeset
17
27432
77d25b913f80 changegroup: introduce cg3, which has support for exchanging treemanifests
Augie Fackler <augie@google.com>
parents: 25805
diff changeset
18 testmod('mercurial.changegroup')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
19 testmod('mercurial.changelog')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
20 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
21 testmod('mercurial.dispatch')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
22 testmod('mercurial.encoding')
20799
069bf1b821c8 clone: add doctest for default destination
Yuya Nishihara <yuya@tcha.org>
parents: 20419
diff changeset
23 testmod('mercurial.hg')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
24 testmod('mercurial.hgweb.hgwebdir_mod')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
25 testmod('mercurial.match')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
26 testmod('mercurial.minirst')
24243
daee2039dd11 patch.pathtransform: add doctests
Siddharth Agarwal <sid0@fb.com>
parents: 22546
diff changeset
27 testmod('mercurial.patch')
21568
8dd17b19e722 subrepo: normalize path in the specific way for problematic encodings
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20840
diff changeset
28 testmod('mercurial.pathutil')
25306
c87b05925054 parser: add helper to reduce nesting of chained infix operations
Yuya Nishihara <yuya@tcha.org>
parents: 24243
diff changeset
29 testmod('mercurial.parser')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
30 testmod('mercurial.revset')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
31 testmod('mercurial.store')
20840
308344d80fe5 subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents: 20799
diff changeset
32 testmod('mercurial.subrepo')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
33 testmod('mercurial.templatefilters')
25783
1f6878c87c25 templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents: 25306
diff changeset
34 testmod('mercurial.templater')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
35 testmod('mercurial.ui')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
36 testmod('mercurial.url')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
37 testmod('mercurial.util')
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
38 testmod('mercurial.util', testtarget='platform')
25805
584044e5ad57 convert: use 'default' for specifying branch name in branchmap (issue4753)
Eugene Baranov <eug.baranov@gmail.com>
parents: 25788
diff changeset
39 testmod('hgext.convert.convcmd')
20047
10a7d2bcb81b tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents: 19098
diff changeset
40 testmod('hgext.convert.cvsps')
20048
da99ebd35f00 convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents: 20047
diff changeset
41 testmod('hgext.convert.filemap')
25788
a36fd0993522 convert: unescape Perforce-escaped special characters in filenames
Eugene Baranov <eug.baranov@gmail.com>
parents: 25783
diff changeset
42 testmod('hgext.convert.p4')
20419
e61a8395c3c1 convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents: 20048
diff changeset
43 testmod('hgext.convert.subversion')
22546
aac5482db318 mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents: 21568
diff changeset
44 testmod('hgext.mq')