Show More
@@ -1,95 +1,94 b'' | |||
|
1 | 1 | # this is hack to make sure no escape characters are inserted into the output |
|
2 | 2 | |
|
3 | 3 | from __future__ import absolute_import |
|
4 | 4 | |
|
5 | 5 | import doctest |
|
6 | 6 | import os |
|
7 | 7 | import re |
|
8 | 8 | import sys |
|
9 | 9 | |
|
10 | 10 | ispy3 = sys.version_info[0] >= 3 |
|
11 | 11 | |
|
12 | 12 | if 'TERM' in os.environ: |
|
13 | 13 | del os.environ['TERM'] |
|
14 | 14 | |
|
15 | 15 | |
|
16 | 16 | class py3docchecker(doctest.OutputChecker): |
|
17 | 17 | def check_output(self, want, got, optionflags): |
|
18 | 18 | want2 = re.sub(r'''\bu(['"])(.*?)\1''', r'\1\2\1', want) # py2: u'' |
|
19 | 19 | got2 = re.sub(r'''\bb(['"])(.*?)\1''', r'\1\2\1', got) # py3: b'' |
|
20 | 20 | # py3: <exc.name>: b'<msg>' -> <name>: <msg> |
|
21 | 21 | # <exc.name>: <others> -> <name>: <others> |
|
22 | 22 | got2 = re.sub( |
|
23 | 23 | r'''^mercurial\.\w+\.(\w+): (['"])(.*?)\2''', |
|
24 | 24 | r'\1: \3', |
|
25 | 25 | got2, |
|
26 | 26 | re.MULTILINE, |
|
27 | 27 | ) |
|
28 | 28 | got2 = re.sub(r'^mercurial\.\w+\.(\w+): ', r'\1: ', got2, re.MULTILINE) |
|
29 | 29 | return any( |
|
30 | 30 | doctest.OutputChecker.check_output(self, w, g, optionflags) |
|
31 | 31 | for w, g in [(want, got), (want2, got2)] |
|
32 | 32 | ) |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | def testmod(name, optionflags=0, testtarget=None): |
|
36 | 36 | __import__(name) |
|
37 | 37 | mod = sys.modules[name] |
|
38 | 38 | if testtarget is not None: |
|
39 | 39 | mod = getattr(mod, testtarget) |
|
40 | 40 | |
|
41 | 41 | # minimal copy of doctest.testmod() |
|
42 | 42 | finder = doctest.DocTestFinder() |
|
43 | 43 | checker = None |
|
44 | 44 | if ispy3: |
|
45 | 45 | checker = py3docchecker() |
|
46 | 46 | runner = doctest.DocTestRunner(checker=checker, optionflags=optionflags) |
|
47 | 47 | for test in finder.find(mod, name): |
|
48 | 48 | runner.run(test) |
|
49 | 49 | runner.summarize() |
|
50 | 50 | |
|
51 | 51 | |
|
52 | testmod('mercurial.changegroup') | |
|
53 | 52 | testmod('mercurial.changelog') |
|
54 | 53 | testmod('mercurial.cmdutil') |
|
55 | 54 | testmod('mercurial.color') |
|
56 | 55 | testmod('mercurial.config') |
|
57 | testmod('mercurial.context') | |
|
58 | 56 | testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE) |
|
59 | testmod('mercurial.dispatch') | |
|
60 | 57 | testmod('mercurial.encoding') |
|
61 | 58 | testmod('mercurial.fancyopts') |
|
62 | 59 | testmod('mercurial.formatter') |
|
63 | 60 | testmod('mercurial.hg') |
|
64 | 61 | testmod('mercurial.hgweb.hgwebdir_mod') |
|
65 | 62 | testmod('mercurial.match') |
|
66 | 63 | testmod('mercurial.mdiff') |
|
67 | 64 | testmod('mercurial.minirst') |
|
65 | testmod('mercurial.parser') | |
|
68 | 66 | testmod('mercurial.patch') |
|
69 | 67 | testmod('mercurial.pathutil') |
|
70 | testmod('mercurial.parser') | |
|
71 | 68 | testmod('mercurial.pycompat') |
|
72 | testmod('mercurial.revlog') | |
|
73 | 69 | testmod('mercurial.revlogutils.deltas') |
|
74 | 70 | testmod('mercurial.revset') |
|
75 | 71 | testmod('mercurial.revsetlang') |
|
72 | testmod('mercurial.simplemerge') | |
|
76 | 73 | testmod('mercurial.smartset') |
|
77 | 74 | testmod('mercurial.store') |
|
78 | 75 | testmod('mercurial.subrepo') |
|
79 | testmod('mercurial.templatefilters') | |
|
80 | 76 | testmod('mercurial.templater') |
|
81 | 77 | testmod('mercurial.ui') |
|
82 | testmod('mercurial.url') | |
|
83 | 78 | testmod('mercurial.util') |
|
84 | testmod('mercurial.util', testtarget='platform') | |
|
79 | testmod('mercurial.util', testtarget='platform') # windows.py or posix.py | |
|
85 | 80 | testmod('mercurial.utils.dateutil') |
|
86 | 81 | testmod('mercurial.utils.stringutil') |
|
87 | 82 | testmod('hgext.convert.convcmd') |
|
88 | 83 | testmod('hgext.convert.cvsps') |
|
89 | 84 | testmod('hgext.convert.filemap') |
|
90 | 85 | testmod('hgext.convert.p4') |
|
91 | 86 | testmod('hgext.convert.subversion') |
|
92 | 87 | testmod('hgext.fix') |
|
93 | 88 | testmod('hgext.mq') |
|
94 | 89 | # Helper scripts in tests/ that have doctests: |
|
95 | 90 | testmod('drawdag') |
|
91 | testmod('test-run-tests') | |
|
92 | ||
|
93 | # Disabled since it requires extra modules that might not be installed. | |
|
94 | # testmod('i18n.check-translation') |
General Comments 0
You need to be logged in to leave comments.
Login now