sapling/tests/comprehensive/test-hgsubversion-sqlite-revmap.py
Kostia Balytskyi f47acc0834 hgsubversion: fixup comprehensive tests imports
Summary:
Here we make imports in `hgsubversion` tests work again.
This consists of two main parts:
1. tests were importing each other as python modules. Now that they have `-` in
their names, it is impossible. However, we can utilize some tricks to work
around this (`imp.load_source`)
2. tests where doing some weird location assumptions, we clean that up


Depends on D6719890

Test Plan: - `./run-tests -l test-hgsubversion-*`, see non-import-exception failures

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6719894
2018-01-17 03:23:44 -08:00

72 lines
2.4 KiB
Python

# no-check-code -- see T24862348
import os
import sys
import test_hgsubversion_util
# 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')
from hgext.hgsubversion import svnmeta, maps
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__)