2008-09-18 15:48:41 +04:00
|
|
|
# this is hack to make sure no escape characters are inserted into the output
|
2016-04-16 01:08:23 +03:00
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import doctest
|
|
|
|
import os
|
2017-08-24 16:33:28 +03:00
|
|
|
import re
|
2016-04-16 01:08:23 +03:00
|
|
|
import sys
|
2017-03-08 16:13:32 +03:00
|
|
|
|
|
|
|
ispy3 = (sys.version_info[0] >= 3)
|
|
|
|
|
2008-10-11 18:40:59 +04:00
|
|
|
if 'TERM' in os.environ:
|
2008-10-20 16:51:55 +04:00
|
|
|
del os.environ['TERM']
|
2006-10-03 00:35:37 +04:00
|
|
|
|
2017-08-24 16:33:28 +03:00
|
|
|
class py3docchecker(doctest.OutputChecker):
|
|
|
|
def check_output(self, want, got, optionflags):
|
|
|
|
want2 = re.sub(r'''\bu(['"])(.*?)\1''', r'\1\2\1', want) # py2: u''
|
|
|
|
got2 = re.sub(r'''\bb(['"])(.*?)\1''', r'\1\2\1', got) # py3: b''
|
|
|
|
# py3: <exc.name>: b'<msg>' -> <name>: <msg>
|
|
|
|
# <exc.name>: <others> -> <name>: <others>
|
|
|
|
got2 = re.sub(r'''^mercurial\.\w+\.(\w+): (['"])(.*?)\2''', r'\1: \3',
|
|
|
|
got2, re.MULTILINE)
|
|
|
|
got2 = re.sub(r'^mercurial\.\w+\.(\w+): ', r'\1: ', got2, re.MULTILINE)
|
|
|
|
return any(doctest.OutputChecker.check_output(self, w, g, optionflags)
|
|
|
|
for w, g in [(want, got), (want2, got2)])
|
|
|
|
|
2017-09-27 15:38:48 +03:00
|
|
|
def testmod(name, optionflags=0, testtarget=None):
|
2013-11-17 20:16:59 +04:00
|
|
|
__import__(name)
|
|
|
|
mod = sys.modules[name]
|
|
|
|
if testtarget is not None:
|
|
|
|
mod = getattr(mod, testtarget)
|
2017-08-24 16:33:28 +03:00
|
|
|
|
|
|
|
# minimal copy of doctest.testmod()
|
|
|
|
finder = doctest.DocTestFinder()
|
|
|
|
checker = None
|
|
|
|
if ispy3:
|
|
|
|
checker = py3docchecker()
|
|
|
|
runner = doctest.DocTestRunner(checker=checker, optionflags=optionflags)
|
|
|
|
for test in finder.find(mod, name):
|
|
|
|
runner.run(test)
|
|
|
|
runner.summarize()
|
2013-11-17 20:16:59 +04:00
|
|
|
|
2015-12-11 19:23:49 +03:00
|
|
|
testmod('mercurial.changegroup')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.changelog')
|
2017-03-18 14:11:15 +03:00
|
|
|
testmod('mercurial.color')
|
2017-03-17 19:19:56 +03:00
|
|
|
testmod('mercurial.config')
|
2017-05-25 05:07:14 +03:00
|
|
|
testmod('mercurial.context')
|
2017-09-03 09:32:45 +03:00
|
|
|
testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.dispatch')
|
2018-01-30 19:02:09 +03:00
|
|
|
testmod('mercurial.drawdag')
|
2017-09-16 16:55:48 +03:00
|
|
|
testmod('mercurial.encoding')
|
2017-11-23 16:04:53 +03:00
|
|
|
testmod('mercurial.fancyopts')
|
2017-09-17 06:39:53 +03:00
|
|
|
testmod('mercurial.formatter')
|
2014-03-21 19:46:08 +04:00
|
|
|
testmod('mercurial.hg')
|
2017-09-27 13:04:32 +03:00
|
|
|
testmod('mercurial.hgweb.hgwebdir_mod')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.match')
|
2017-04-01 13:24:59 +03:00
|
|
|
testmod('mercurial.mdiff')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.minirst')
|
2017-09-17 06:23:16 +03:00
|
|
|
testmod('mercurial.patch')
|
2017-09-17 06:26:42 +03:00
|
|
|
testmod('mercurial.pathutil')
|
2015-04-26 12:05:23 +03:00
|
|
|
testmod('mercurial.parser')
|
2017-09-03 09:09:04 +03:00
|
|
|
testmod('mercurial.pycompat')
|
2017-02-19 12:19:33 +03:00
|
|
|
testmod('mercurial.revsetlang')
|
2016-10-16 11:28:51 +03:00
|
|
|
testmod('mercurial.smartset')
|
2017-09-03 11:28:47 +03:00
|
|
|
testmod('mercurial.store')
|
2014-03-22 03:09:17 +04:00
|
|
|
testmod('mercurial.subrepo')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.templatefilters')
|
2015-06-15 17:11:35 +03:00
|
|
|
testmod('mercurial.templater')
|
2017-09-03 11:47:21 +03:00
|
|
|
testmod('mercurial.ui')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.url')
|
2017-09-27 13:27:41 +03:00
|
|
|
testmod('mercurial.util')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('mercurial.util', testtarget='platform')
|
2017-09-27 13:08:23 +03:00
|
|
|
testmod('hgext.convert.convcmd')
|
2013-11-17 20:16:59 +04:00
|
|
|
testmod('hgext.convert.cvsps')
|
2013-11-17 20:18:39 +04:00
|
|
|
testmod('hgext.convert.filemap')
|
2015-07-14 18:23:57 +03:00
|
|
|
testmod('hgext.convert.p4')
|
2014-02-07 20:28:37 +04:00
|
|
|
testmod('hgext.convert.subversion')
|
2014-09-24 04:41:11 +04:00
|
|
|
testmod('hgext.mq')
|