author | Raphaël Gomès <rgomes@octobus.net> |
Mon, 04 Nov 2024 15:23:41 +0100 | |
changeset 52311 | f7b2806035a7 |
parent 52135 | cf8d029a480b |
permissions | -rw-r--r-- |
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 |
|
6262f0215d08
tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27432
diff
changeset
|
4 |
import doctest |
45657
4a146cff76fa
tests: fix test-check-module-imports.t broken by D9150
Martin von Zweigbergk <martinvonz@google.com>
parents:
45633
diff
changeset
|
5 |
import os |
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
6 |
import re |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
7 |
import subprocess |
28933
6262f0215d08
tests: make test-doctest use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27432
diff
changeset
|
8 |
import sys |
31438
82350f7fa56c
tests: allow running doctests selectively on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
31024
diff
changeset
|
9 |
|
7078
967adcf5910d
test-doctest: remove TERM env variable only if it's there
Patrick Mezard <pmezard@gmail.com>
parents:
7041
diff
changeset
|
10 |
if 'TERM' in os.environ: |
7184
380fda3eed13
clean up trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7078
diff
changeset
|
11 |
del os.environ['TERM'] |
3232
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
12 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
13 |
|
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
14 |
class py3docchecker(doctest.OutputChecker): |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
15 |
def check_output(self, want, got, optionflags): |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
16 |
want2 = re.sub(r'''\bu(['"])(.*?)\1''', r'\1\2\1', want) # py2: u'' |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
17 |
got2 = re.sub(r'''\bb(['"])(.*?)\1''', r'\1\2\1', got) # py3: b'' |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
18 |
# py3: <exc.name>: b'<msg>' -> <name>: <msg> |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
19 |
# <exc.name>: <others> -> <name>: <others> |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
20 |
got2 = re.sub( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
21 |
r'''^mercurial\.\w+\.(\w+): (['"])(.*?)\2''', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
22 |
r'\1: \3', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
23 |
got2, |
52107
4fbee56e854a
tests: pass re.MULTILINE to re.sub as 'flags' - not in 'count' position
Mads Kiilerich <mads@kiilerich.com>
parents:
51962
diff
changeset
|
24 |
flags=re.MULTILINE, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
25 |
) |
52107
4fbee56e854a
tests: pass re.MULTILINE to re.sub as 'flags' - not in 'count' position
Mads Kiilerich <mads@kiilerich.com>
parents:
51962
diff
changeset
|
26 |
got2 = re.sub( |
4fbee56e854a
tests: pass re.MULTILINE to re.sub as 'flags' - not in 'count' position
Mads Kiilerich <mads@kiilerich.com>
parents:
51962
diff
changeset
|
27 |
r'^mercurial\.\w+\.(\w+): ', r'\1: ', got2, flags=re.MULTILINE |
4fbee56e854a
tests: pass re.MULTILINE to re.sub as 'flags' - not in 'count' position
Mads Kiilerich <mads@kiilerich.com>
parents:
51962
diff
changeset
|
28 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
29 |
return any( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
30 |
doctest.OutputChecker.check_output(self, w, g, optionflags) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
31 |
for w, g in [(want, got), (want2, got2)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
32 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
33 |
|
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
34 |
|
34424
e416819d9ebb
doctest: drop hack to run py2/3 tests selectively
Yuya Nishihara <yuya@tcha.org>
parents:
34362
diff
changeset
|
35 |
def testmod(name, optionflags=0, testtarget=None): |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
36 |
__import__(name) |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
37 |
mod = sys.modules[name] |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
38 |
if testtarget is not None: |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
39 |
mod = getattr(mod, testtarget) |
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
40 |
|
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
41 |
# minimal copy of doctest.testmod() |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
42 |
finder = doctest.DocTestFinder() |
49872
40060267df22
tests: drop py2 support from test-doctest.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
48875
diff
changeset
|
43 |
checker = py3docchecker() |
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
44 |
runner = doctest.DocTestRunner(checker=checker, optionflags=optionflags) |
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
45 |
for test in finder.find(mod, name): |
52135
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
46 |
# Windows doesn't have time.tzset(), so skip methods that invoke it in |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
47 |
# a doctest, without hardcoding the function name. There is a feature |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
48 |
# request for adding syntax to the test itself to conditionally skip |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
49 |
# that would make this unnecessary: |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
50 |
# |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
51 |
# https://github.com/python/cpython/issues/117364 |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
52 |
for example in test.examples: |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
53 |
if os.name == 'nt' and 'time.tzset()' in example.source: |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
54 |
break |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
55 |
else: |
cf8d029a480b
tests: skip doctests that use `time.tzset()` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
52134
diff
changeset
|
56 |
runner.run(test) |
34140
52ec9ac0303b
doctest: normalize b'', u'' and exception output on Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
32485
diff
changeset
|
57 |
runner.summarize() |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
13949
diff
changeset
|
58 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41359
diff
changeset
|
59 |
|
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
60 |
DONT_RUN = [] |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
61 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
62 |
# Exceptions to the defaults for a given detected module. The value for each |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
63 |
# module name is a list of dicts that specify the kwargs to pass to testmod. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
64 |
# testmod is called once per item in the list, so an empty list will cause the |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
65 |
# module to not be tested. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
66 |
testmod_arg_overrides = { |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
67 |
'i18n.check-translation': DONT_RUN, # may require extra installation |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
68 |
'mercurial.dagparser': [{'optionflags': doctest.NORMALIZE_WHITESPACE}], |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
69 |
'mercurial.keepalive': DONT_RUN, # >>> is an example, not a doctest |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
70 |
'mercurial.posix': DONT_RUN, # run by mercurial.platform |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
71 |
'mercurial.statprof': DONT_RUN, # >>> is an example, not a doctest |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
72 |
'mercurial.util': [{}, {'testtarget': 'platform'}], # run twice! |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
73 |
'mercurial.windows': DONT_RUN, # run by mercurial.platform |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
74 |
'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}], |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
75 |
} |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
76 |
|
44656
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
77 |
fileset = 'set:(**.py)' |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
78 |
|
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
79 |
cwd = os.path.dirname(os.environ["TESTDIR"]) |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
80 |
|
45633
5a19d7c9129b
tests: skip doctests if not running from a hg repo
Joerg Sonnenberger <joerg@bec.de>
parents:
44656
diff
changeset
|
81 |
if not os.path.isdir(os.path.join(cwd, ".hg")): |
5a19d7c9129b
tests: skip doctests if not running from a hg repo
Joerg Sonnenberger <joerg@bec.de>
parents:
44656
diff
changeset
|
82 |
sys.exit(0) |
5a19d7c9129b
tests: skip doctests if not running from a hg repo
Joerg Sonnenberger <joerg@bec.de>
parents:
44656
diff
changeset
|
83 |
|
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
84 |
files = subprocess.check_output( |
52134
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
85 |
[ |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
86 |
"sh", |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
87 |
"-c", |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
88 |
"set -e; . helpers-testrepo.sh; testrepohg files --print0 \"%s\"" |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
89 |
% fileset, |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
90 |
], |
479899e53816
tests: hopefully fix `test-doctest.py` on Windows and more
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52113
diff
changeset
|
91 |
shell=False, |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45657
diff
changeset
|
92 |
cwd=cwd, |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
93 |
).split(b'\0') |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
94 |
|
44656
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
95 |
if sys.version_info[0] >= 3: |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
96 |
cwd = os.fsencode(cwd) |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
97 |
|
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
98 |
mods_tested = set() |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
99 |
for f in files: |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
100 |
if not f: |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
101 |
continue |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
102 |
|
44656
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
103 |
with open(os.path.join(cwd, f), "rb") as fh: |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
104 |
if not re.search(br'\n\s*>>>', fh.read()): |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
105 |
continue |
15aef805619d
tests: perform grep manually in test-doctest.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44565
diff
changeset
|
106 |
|
49872
40060267df22
tests: drop py2 support from test-doctest.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
48875
diff
changeset
|
107 |
f = f.decode() |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
108 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
109 |
modname = f.replace('.py', '').replace('\\', '.').replace('/', '.') |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
110 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
111 |
# Third-party modules aren't our responsibility to test, and the modules in |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
112 |
# contrib generally do not have doctests in a good state, plus they're hard |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
113 |
# to import if this test is running with py2, so we just skip both for now. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
114 |
if modname.startswith('mercurial.thirdparty.') or modname.startswith( |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
115 |
'contrib.' |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
116 |
): |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
117 |
continue |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
118 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
119 |
for kwargs in testmod_arg_overrides.get(modname, [{}]): |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
120 |
mods_tested.add((modname, '%r' % (kwargs,))) |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
121 |
if modname.startswith('tests.'): |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
122 |
# On py2, we can't import from tests.foo, but it works on both py2 |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
123 |
# and py3 with the way that PYTHONPATH is setup to import without |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
124 |
# the 'tests.' prefix, so we do that. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
125 |
modname = modname[len('tests.') :] |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
126 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
127 |
testmod(modname, **kwargs) |
44564
529cb23155bc
tests: make test-doctest.t module list match reality
Kyle Lippincott <spectral@google.com>
parents:
43780
diff
changeset
|
128 |
|
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
129 |
# Meta-test: let's make sure that we actually ran what we expected to, above. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
130 |
# Each item in the set is a 2-tuple of module name and stringified kwargs passed |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
131 |
# to testmod. |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
132 |
expected_mods_tested = set( |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
133 |
[ |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
134 |
('hgext.convert.convcmd', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
135 |
('hgext.convert.cvsps', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
136 |
('hgext.convert.filemap', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
137 |
('hgext.convert.p4', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
138 |
('hgext.convert.subversion', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
139 |
('hgext.fix', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
140 |
('hgext.mq', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
141 |
('mercurial.changelog', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
142 |
('mercurial.cmdutil', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
143 |
('mercurial.color', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
144 |
('mercurial.dagparser', "{'optionflags': 4}"), |
48741
46d12f7762e4
dirstate-v2: fix infinite loop in pure packer
Raphaël Gomès <rgomes@octobus.net>
parents:
47189
diff
changeset
|
145 |
('mercurial.dirstateutils.v2', '{}'), |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
146 |
('mercurial.encoding', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
147 |
('mercurial.fancyopts', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
148 |
('mercurial.formatter', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
149 |
('mercurial.hg', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
150 |
('mercurial.hgweb.hgwebdir_mod', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
151 |
('mercurial.match', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
152 |
('mercurial.mdiff', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
153 |
('mercurial.minirst', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
154 |
('mercurial.parser', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
155 |
('mercurial.patch', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
156 |
('mercurial.pathutil', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
157 |
('mercurial.pycompat', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
158 |
('mercurial.revlogutils.deltas', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
159 |
('mercurial.revset', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
160 |
('mercurial.revsetlang', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
161 |
('mercurial.simplemerge', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
162 |
('mercurial.smartset', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
163 |
('mercurial.store', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
164 |
('mercurial.subrepo', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
165 |
('mercurial.templater', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
166 |
('mercurial.ui', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
167 |
('mercurial.util', "{'testtarget': 'platform'}"), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
168 |
('mercurial.util', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
169 |
('mercurial.utils.dateutil', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
170 |
('mercurial.utils.stringutil', '{}'), |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45942
diff
changeset
|
171 |
('mercurial.utils.urlutil', '{}'), |
44565
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
172 |
('tests.drawdag', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
173 |
('tests.test-run-tests', '{}'), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
174 |
('tests.test-url', "{'optionflags': 4}"), |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
175 |
] |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
176 |
) |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
177 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
178 |
unexpectedly_run = mods_tested.difference(expected_mods_tested) |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
179 |
not_run = expected_mods_tested.difference(mods_tested) |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
180 |
|
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
181 |
if unexpectedly_run: |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
182 |
print('Unexpectedly ran (probably need to add to list):') |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
183 |
for r in sorted(unexpectedly_run): |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
184 |
print(' %r' % (r,)) |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
185 |
if not_run: |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
186 |
print('Expected to run, but was not run (doctest removed?):') |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
187 |
for r in sorted(not_run): |
0af56d3ee24c
tests: make test-doctest.t automatically find files to run tests on
Kyle Lippincott <spectral@google.com>
parents:
44564
diff
changeset
|
188 |
print(' %r' % (r,)) |