mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
9dc21f8d0b
Summary: D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`. That has nasty problems if both `import mercurial` and `import edenscm.mercurial` are used, because Python would think `mercurial.foo` and `edenscm.mercurial.foo` are different modules so code like `try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)` would fail to handle the `edenscm.mercurial` version. There are also some module-level states (ex. `extensions._extensions`) that would cause trouble if they have multiple versions in a single process. Change imports to use the `edenscm` so ideally the `mercurial` is no longer imported at all. Add checks in extensions.py to catch unexpected extensions importing modules from the old (wrong) locations when running tests. Reviewed By: phillco Differential Revision: D13868981 fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
# no-check-code -- see T24862348
|
|
|
|
import os
|
|
import sys
|
|
|
|
import test_hgsubversion_util
|
|
from edenscm.hgext.hgsubversion import maps, svnmeta
|
|
|
|
|
|
# interesting and fast tests
|
|
test_fetch_mappings = test_hgsubversion_util.import_test("test_fetch_mappings")
|
|
test_fetch_renames = test_hgsubversion_util.import_test("test_fetch_renames")
|
|
test_pull = test_hgsubversion_util.import_test("test_pull")
|
|
test_template_keywords = test_hgsubversion_util.import_test("test_template_keywords")
|
|
test_utility_commands = test_hgsubversion_util.import_test("test_utility_commands")
|
|
test_custom_layout = test_hgsubversion_util.import_test("test_custom_layout")
|
|
test_rebuildmeta = test_hgsubversion_util.import_test("test_rebuildmeta")
|
|
test_updatemeta = test_hgsubversion_util.import_test("test_updatemeta")
|
|
|
|
|
|
class SqliteRevMapMixIn(object):
|
|
# do not double the test size by being wrapped again
|
|
obsolete_mode_tests = False
|
|
stupid_mode_tests = False
|
|
|
|
def setUp(self):
|
|
assert svnmeta.SVNMeta._defaultrevmapclass is maps.RevMap
|
|
svnmeta.SVNMeta._defaultrevmapclass = maps.SqliteRevMap
|
|
super(SqliteRevMapMixIn, self).setUp()
|
|
|
|
def tearDown(self):
|
|
assert svnmeta.SVNMeta._defaultrevmapclass is maps.SqliteRevMap
|
|
svnmeta.SVNMeta._defaultrevmapclass = maps.RevMap
|
|
super(SqliteRevMapMixIn, self).tearDown()
|
|
|
|
def shortDescription(self):
|
|
text = super(SqliteRevMapMixIn, self).shortDescription()
|
|
if text:
|
|
text += " (sqlite revmap)"
|
|
return text
|
|
|
|
|
|
def buildtestclass(cls, selector=None):
|
|
name = "SqliteRevMap%s" % cls.__name__
|
|
newcls = type(name, (SqliteRevMapMixIn, cls), {})
|
|
|
|
# remove test cases not selected by selector
|
|
if selector:
|
|
for name in dir(newcls):
|
|
if name.startswith("test_") and not selector(name[5:]):
|
|
setattr(newcls, name, None)
|
|
|
|
globals()[name] = newcls
|
|
|
|
|
|
def svndumpselector(name):
|
|
return name in ["branch_rename_to_trunk", "tag_name_same_as_branch"]
|
|
|
|
|
|
buildtestclass(test_fetch_mappings.MapTests)
|
|
buildtestclass(test_fetch_renames.TestFetchRenames)
|
|
buildtestclass(test_pull.TestPull)
|
|
buildtestclass(test_template_keywords.TestLogKeywords)
|
|
buildtestclass(test_utility_commands.UtilityTests)
|
|
|
|
buildtestclass(test_rebuildmeta.RebuildMetaTests, svndumpselector)
|
|
buildtestclass(test_updatemeta.UpdateMetaTests, svndumpselector)
|
|
|
|
if __name__ == "__main__":
|
|
import silenttestrunner
|
|
|
|
silenttestrunner.main(__name__)
|