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
|
|
|
|
2020-01-31 11:16:29 +03:00
|
|
|
from hghave import require
|
2020-01-31 05:40:49 +03:00
|
|
|
|
|
|
|
|
2020-01-31 11:16:29 +03:00
|
|
|
require(["py2"])
|
2020-01-31 05:40:49 +03:00
|
|
|
|
2017-03-08 16:13:32 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ispy3 = sys.version_info[0] >= 3
|
|
|
|
|
|
|
|
if "TERM" in os.environ:
|
|
|
|
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):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
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''
|
2017-08-24 16:33:28 +03:00
|
|
|
# py3: <exc.name>: b'<msg>' -> <name>: <msg>
|
|
|
|
# <exc.name>: <others> -> <name>: <others>
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
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-08-24 16:33:28 +03:00
|
|
|
|
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
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-02-02 04:48:29 +03:00
|
|
|
testmod("edenscm.mercurial.changegroup")
|
|
|
|
testmod("edenscm.mercurial.changelog")
|
|
|
|
testmod("edenscm.mercurial.cmdutil")
|
|
|
|
testmod("edenscm.mercurial.color")
|
|
|
|
testmod("edenscm.mercurial.config")
|
|
|
|
testmod("edenscm.mercurial.context")
|
|
|
|
testmod("edenscm.mercurial.dagparser", optionflags=doctest.NORMALIZE_WHITESPACE)
|
|
|
|
testmod("edenscm.mercurial.dispatch")
|
|
|
|
testmod("edenscm.mercurial.drawdag")
|
|
|
|
testmod("edenscm.mercurial.encoding")
|
|
|
|
testmod("edenscm.mercurial.fancyopts")
|
|
|
|
testmod("edenscm.mercurial.formatter")
|
|
|
|
testmod("edenscm.mercurial.hg")
|
|
|
|
testmod("edenscm.mercurial.hgweb.hgwebdir_mod")
|
|
|
|
testmod("edenscm.mercurial.match")
|
|
|
|
testmod("edenscm.mercurial.mdiff")
|
|
|
|
testmod("edenscm.mercurial.minirst")
|
2019-03-08 14:01:08 +03:00
|
|
|
testmod("edenscm.mercurial.mutation")
|
2019-02-02 04:48:29 +03:00
|
|
|
testmod("edenscm.mercurial.patch")
|
|
|
|
testmod("edenscm.mercurial.pathutil")
|
|
|
|
testmod("edenscm.mercurial.parser")
|
|
|
|
testmod("edenscm.mercurial.pycompat")
|
|
|
|
testmod("edenscm.mercurial.revsetlang")
|
|
|
|
testmod("edenscm.mercurial.smartset")
|
|
|
|
testmod("edenscm.mercurial.store")
|
|
|
|
testmod("edenscm.mercurial.templatefilters")
|
|
|
|
testmod("edenscm.mercurial.templater")
|
|
|
|
testmod("edenscm.mercurial.ui")
|
2019-08-15 22:45:39 +03:00
|
|
|
testmod("edenscm.mercurial.uiconfig")
|
2019-02-02 04:48:29 +03:00
|
|
|
testmod("edenscm.mercurial.url")
|
|
|
|
testmod("edenscm.mercurial.util")
|
|
|
|
testmod("edenscm.mercurial.util", testtarget="platform")
|
2019-05-20 16:11:59 +03:00
|
|
|
testmod("edenscm.hgext.commitcloud.sync")
|
2019-02-02 04:48:29 +03:00
|
|
|
testmod("edenscm.hgext.convert.convcmd")
|
|
|
|
testmod("edenscm.hgext.convert.filemap")
|
|
|
|
testmod("edenscm.hgext.convert.subversion")
|
2019-10-23 22:52:51 +03:00
|
|
|
testmod("edenscm.hgext.convert.p4")
|
2019-02-02 04:48:29 +03:00
|
|
|
testmod("edenscm.hgext.gitlookup")
|