annotate tests/test-bad-extension.t @ 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 ebe488e04ca3
children 84f9eb9758c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11858
934c7e91c126 tests: unify test-bad-extension
Martin Geisler <mg@lazybytes.net>
parents: 6204
diff changeset
1 $ echo 'raise Exception("bit bucket overflow")' > badext.py
28083
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
2 $ abspathexc=`pwd`/badext.py
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
3
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
4 $ cat >baddocext.py <<EOF
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
5 > """
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
6 > baddocext is bad
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
7 > """
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
8 > EOF
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
9 $ abspathdoc=`pwd`/baddocext.py
3014
01454af644b8 load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
10
23172
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
11 $ cat <<EOF >> $HGRCPATH
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
12 > [extensions]
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
13 > gpg =
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
14 > hgext.gpg =
28083
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
15 > badext = $abspathexc
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
16 > baddocext = $abspathdoc
23172
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
17 > badext2 =
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 14286
diff changeset
18 > EOF
3014
01454af644b8 load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
19
26239
f39953663cc9 test-bad-extension: reduce dependencies on other things
timeless@mozdev.org
parents: 25364
diff changeset
20 $ hg -q help help 2>&1 |grep extension
12640
6cc4b14fb76b tests: remove redundant globs
Mads Kiilerich <mads@kiilerich.com>
parents: 12376
diff changeset
21 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents: 11858
diff changeset
22 *** failed to import extension badext2: No module named badext2
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
23
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
24 show traceback
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
25
26239
f39953663cc9 test-bad-extension: reduce dependencies on other things
timeless@mozdev.org
parents: 25364
diff changeset
26 $ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError'
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
27 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
28 Traceback (most recent call last):
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
29 Exception: bit bucket overflow
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
30 *** failed to import extension badext2: No module named badext2
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
31 Traceback (most recent call last):
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
32 ImportError: No module named badext2
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
33
28155
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
34 names of extensions failed to load can be accessed via extensions.notloaded()
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
35
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
36 $ cat <<EOF > showbadexts.py
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
37 > from mercurial import cmdutil, commands, extensions
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
38 > cmdtable = {}
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
39 > command = cmdutil.command(cmdtable)
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
40 > @command('showbadexts', norepo=True)
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
41 > def showbadexts(ui, *pats, **opts):
28338
9974b8236cac tests: Solaris grep doesn't add a trailing newline when it's missing
Danek Duvall <danek.duvall@oracle.com>
parents: 28155
diff changeset
42 > ui.write('BADEXTS: %s\n' % ' '.join(sorted(extensions.notloaded())))
28155
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
43 > EOF
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
44 $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS'
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
45 BADEXTS: badext badext2
7f430b2ac7fd extensions: add notloaded method to return extensions failed to load
Jun Wu <quark@fb.com>
parents: 28083
diff changeset
46
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
47 show traceback for ImportError of hgext.name if debug is set
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
48 (note that --debug option isn't applied yet when loading extensions)
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
49
26239
f39953663cc9 test-bad-extension: reduce dependencies on other things
timeless@mozdev.org
parents: 25364
diff changeset
50 $ (hg -q help help --traceback --config ui.debug=True 2>&1) \
f39953663cc9 test-bad-extension: reduce dependencies on other things
timeless@mozdev.org
parents: 25364
diff changeset
51 > | grep -v '^ ' \
f39953663cc9 test-bad-extension: reduce dependencies on other things
timeless@mozdev.org
parents: 25364
diff changeset
52 > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import'
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
53 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
54 Traceback (most recent call last):
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
55 Exception: bit bucket overflow
30027
ebe488e04ca3 extensions: fix a debug message when searching for extensions
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28737
diff changeset
56 could not import hgext.badext2 (No module named *badext2): trying hgext3rd.badext2 (glob)
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
57 Traceback (most recent call last):
27538
50ad3f25fb4c test-bad-extension: account for PyPy/CPython error difference
Bryan O'Sullivan <bos@serpentine.com>
parents: 26239
diff changeset
58 ImportError: No module named *badext2 (glob)
28737
a3a01194a337 pypy: fix overspecific test checks
Maciej Fijalkowski <fijall@gmail.com>
parents: 28541
diff changeset
59 could not import hgext3rd.badext2 (No module named *badext2): trying badext2 (glob)
28541
4b81487a01d4 extensions: also search for extension in the 'hgext3rd' package
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28338
diff changeset
60 Traceback (most recent call last):
28737
a3a01194a337 pypy: fix overspecific test checks
Maciej Fijalkowski <fijall@gmail.com>
parents: 28541
diff changeset
61 ImportError: No module named *badext2 (glob)
25364
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
62 *** failed to import extension badext2: No module named badext2
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
63 Traceback (most recent call last):
de23a552fc23 extensions: show traceback on load failure if --traceback flag is set
Yuya Nishihara <yuya@tcha.org>
parents: 23172
diff changeset
64 ImportError: No module named badext2
28083
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
65
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
66 confirm that there's no crash when an extension's documentation is bad
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
67
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
68 $ hg help --keyword baddocext
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
69 *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
70 *** failed to import extension badext2: No module named badext2
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
71 Topics:
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
72
550097d01ca3 tests: confirm that a badly documented extension doesn't cause a crash
Simon Farnsworth <simonfar@fb.com>
parents: 27538
diff changeset
73 extensions Using Additional Features