# HG changeset patch # User Augie Fackler # Date 1232591271 21600 # Node ID 13ae1bded5e7d3d81e34421195b84b06b1292a46 # Parent 6e3f99ba47ec3435f7bf315f164067a628d85fc5 Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing. diff --git a/tests/comprehensive/test_stupid_pull.py b/tests/comprehensive/test_stupid_pull.py new file mode 100644 --- /dev/null +++ b/tests/comprehensive/test_stupid_pull.py @@ -0,0 +1,50 @@ +import os +import pickle +import unittest + +from mercurial import hg +from mercurial import ui + +from tests import test_util +import rebuildmeta +import hg_delta_editor +import fetch_command + + +def _do_case(self, name): + subdir = test_util.subdir.get(name, '') + self._load_fixture_and_fetch(name, subdir=subdir, stupid=False) + assert len(self.repo) > 0, 'Repo had no changes, maybe you need to add a subdir entry in test_util?' + wc2_path = self.wc_path + '_stupid' + u = ui.ui() + checkout_path = self.repo_path + if subdir: + checkout_path += '/' + subdir + fetch_command.fetch_revisions(ui.ui(), + svn_url=test_util.fileurl(checkout_path), + hg_repo_path=wc2_path, + stupid=True) + self.repo2 = hg.repository(ui.ui(), wc2_path) + self.assertEqual(self.repo.branchtags(), self.repo2.branchtags()) + self.assertEqual(pickle.load(open(os.path.join(self.wc_path, '.hg', 'svn', 'tag_info'))), + pickle.load(open(os.path.join(wc2_path, '.hg', 'svn', 'tag_info')))) + + +def buildmethod(case, name): + m = lambda self: self._do_case(case) + m.__name__ = name + m.__doc__ = 'Test stupid produces same as real on %s.' % case + return m + +attrs = {'_do_case': _do_case, + } +for case in (f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')): + name = 'test_' + case[:-len('.svndump')] + attrs[name] = buildmethod(case, name) +StupidPullTests = type('StupidPullTests', (test_util.TestBase, ), attrs) + + +def suite(): + all = [unittest.TestLoader().loadTestsFromTestCase(StupidPullTests), + ] + return unittest.TestSuite(all) diff --git a/tests/test_rebuildmeta.py b/tests/test_rebuildmeta.py --- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -9,9 +9,6 @@ import test_util import rebuildmeta import hg_delta_editor -subdir = {'truncatedhistory.svndump': '/project2', - 'fetch_missing_files_subdir.svndump': '/foo', - } # List of expected "missing" branches - these are really files that happen # to be in the branches dir. This will be fixed at a later date. expected_branch_deltas = {'unrelatedbranch.svndump': ['c', ], @@ -19,7 +16,8 @@ expected_branch_deltas = {'unrelatedbran } def _do_case(self, name, stupid): - self._load_fixture_and_fetch(name, subdir=subdir.get(name, ''), stupid=stupid) + subdir = test_util.subdir.get(name, '') + self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid) assert len(self.repo) > 0 wc2_path = self.wc_path + '_clone' u = ui.ui() @@ -28,7 +26,7 @@ def _do_case(self, name, stupid): dest, os.path.dirname(dest.path), args=[test_util.fileurl(self.repo_path + - subdir.get(name, '')), ]) + subdir), ]) dest = hg.repository(u, os.path.dirname(dest.path)) self.assert_(open(os.path.join(src.path, 'svn', 'last_rev')).read() >= open(os.path.join(dest.path, 'svn', 'last_rev')).read()) diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -16,6 +16,11 @@ from mercurial import ui import fetch_command import push_cmd +# Fixtures that need to be pulled at a subdirectory of the repo path +subdir = {'truncatedhistory.svndump': '/project2', + 'fetch_missing_files_subdir.svndump': '/foo', + } + FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fixtures')