Mercurial > hgsubversion
comparison tests/comprehensive/test_updatemeta.py @ 1042:af84ef787d93
tests: move updatemeta & rebuildmeta tests into comprehensive
this decreases normal the test count from 689 to 269, as both iterate
over all our fixture, and test_utility_commands already tests both
rudimentarily.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Wed, 07 Aug 2013 09:57:54 +0200 |
| parents | tests/test_updatemeta.py@5bacb9c63e3e |
| children | d741f536f23a |
comparison
equal
deleted
inserted
replaced
| 1041:70090e2ee262 | 1042:af84ef787d93 |
|---|---|
| 1 import os | |
| 2 import pickle | |
| 3 import unittest | |
| 4 | |
| 5 # wrapped in a try/except because of weirdness in how | |
| 6 # run.py works as compared to nose. | |
| 7 try: | |
| 8 import test_util | |
| 9 except ImportError: | |
| 10 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) | |
| 11 import test_util | |
| 12 | |
| 13 import test_rebuildmeta | |
| 14 | |
| 15 from mercurial import context | |
| 16 from mercurial import extensions | |
| 17 from mercurial import hg | |
| 18 from mercurial import ui | |
| 19 | |
| 20 from hgsubversion import svncommands | |
| 21 from hgsubversion import svnmeta | |
| 22 | |
| 23 | |
| 24 | |
| 25 def _do_case(self, name, stupid, single): | |
| 26 subdir = test_util.subdir.get(name, '') | |
| 27 layout = 'auto' | |
| 28 if single: | |
| 29 layout = 'single' | |
| 30 repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid, | |
| 31 layout=layout) | |
| 32 assert len(self.repo) > 0 | |
| 33 wc2_path = self.wc_path + '_clone' | |
| 34 u = ui.ui() | |
| 35 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) | |
| 36 src = test_util.getlocalpeer(src) | |
| 37 dest = test_util.getlocalpeer(dest) | |
| 38 | |
| 39 # insert a wrapper that prevents calling changectx.children() | |
| 40 def failfn(orig, ctx): | |
| 41 self.fail('calling %s is forbidden; it can cause massive slowdowns ' | |
| 42 'when rebuilding large repositories' % orig) | |
| 43 | |
| 44 origchildren = getattr(context.changectx, 'children') | |
| 45 extensions.wrapfunction(context.changectx, 'children', failfn) | |
| 46 | |
| 47 # test updatemeta on an empty repo | |
| 48 try: | |
| 49 svncommands.updatemeta(u, dest, | |
| 50 args=[test_util.fileurl(repo_path + | |
| 51 subdir), ]) | |
| 52 finally: | |
| 53 # remove the wrapper | |
| 54 context.changectx.children = origchildren | |
| 55 | |
| 56 self._run_assertions(name, stupid, single, src, dest, u) | |
| 57 | |
| 58 | |
| 59 def _run_assertions(self, name, stupid, single, src, dest, u): | |
| 60 test_rebuildmeta._run_assertions(self, name, stupid, single, src, dest, u) | |
| 61 | |
| 62 | |
| 63 skip = set([ | |
| 64 'project_root_not_repo_root.svndump', | |
| 65 'corrupt.svndump', | |
| 66 ]) | |
| 67 | |
| 68 attrs = {'_do_case': _do_case, | |
| 69 '_run_assertions': _run_assertions, | |
| 70 } | |
| 71 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: | |
| 72 # this fixture results in an empty repository, don't use it | |
| 73 if case in skip: | |
| 74 continue | |
| 75 bname = 'test_' + case[:-len('.svndump')] | |
| 76 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False, False) | |
| 77 name = bname + '_stupid' | |
| 78 attrs[name] = test_rebuildmeta.buildmethod(case, name, True, False) | |
| 79 name = bname + '_single' | |
| 80 attrs[name] = test_rebuildmeta.buildmethod(case, name, False, True) | |
| 81 | |
| 82 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs) | |
| 83 | |
| 84 | |
| 85 def suite(): | |
| 86 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UpdateMetaTests), | |
| 87 ] | |
| 88 return unittest.TestSuite(all_tests) |
