Mercurial > hgsubversion
view tests/test_single_dir_clone.py @ 1056:0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
We use a metaclass similar to the tests for obsolete mode. This
metaclass deliberately duplicates each test for each mode; enabling
both means that each test function is run four times.
This makes it less likely that a fix is accidentally applied to replay
mode only, as new tests will often automatically cover both
modes. However, as certiain features remain deliberately unimplemented
in stupid modes -- filemaps being a notable example -- we also add a
decorator function for marking methods testing them.
We do this for reasons of both consistency and coverage; we avoid
littering the tests with *_stupid variants, and thus are less likely
to forget adding them. I already found a couple of bugs in stupid mode
thanks to this increased coverage.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 09 Aug 2013 23:34:16 +0200 |
parents | 3092b3c109a8 |
children | 2668785264d7 |
line wrap: on
line source
import test_util import errno import shutil import unittest from mercurial import commands from mercurial import context from mercurial import hg from mercurial import node from mercurial import ui class TestSingleDirClone(test_util.TestBase): def test_clone_single_dir_simple(self): repo = self._load_fixture_and_fetch('branch_from_tag.svndump', stupid=False, layout='single', subdir='') self.assertEqual(repo.branchtags().keys(), ['default']) self.assertEqual(repo['tip'].manifest().keys(), ['trunk/beta', 'tags/copied_tag/alpha', 'trunk/alpha', 'tags/copied_tag/beta', 'branches/branch_from_tag/alpha', 'tags/tag_r3/alpha', 'tags/tag_r3/beta', 'branches/branch_from_tag/beta']) def test_auto_detect_single(self): repo = self._load_fixture_and_fetch('branch_from_tag.svndump', stupid=False, layout='auto') self.assertEqual(repo.branchtags().keys(), ['default', 'branch_from_tag']) oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys()) # remove standard layout shutil.rmtree(self.wc_path) # try again with subdir to get single dir clone repo = self._load_fixture_and_fetch('branch_from_tag.svndump', stupid=False, layout='auto', subdir='trunk') self.assertEqual(repo.branchtags().keys(), ['default', ]) self.assertEqual(repo['default'].manifest().keys(), oldmanifest) def test_clone_subdir_is_file_prefix(self, stupid=False): FIXTURE = 'subdir_is_file_prefix.svndump' repo = self._load_fixture_and_fetch(FIXTURE, stupid=stupid, layout='single', subdir=test_util.subdir[FIXTURE]) self.assertEqual(repo.branchtags().keys(), ['default']) self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt']) def test_externals_single(self): repo = self._load_fixture_and_fetch('externals.svndump', stupid=False, layout='single') for rev in repo: assert '.hgsvnexternals' not in repo[rev].manifest() return # TODO enable test when externals in single are fixed expect = """[.] -r2 ^/externals/project2@2 deps/project2 [subdir] ^/externals/project1 deps/project1 [subdir2] ^/externals/project1 deps/project1 """ test = 2 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) def test_externals_single_whole_repo(self): # This is the test which demonstrates the brokenness of externals return # TODO enable test when externals in single are fixed repo = self._load_fixture_and_fetch('externals.svndump', stupid=False, layout='single', subdir='') for rev in repo: rc = repo[rev] if '.hgsvnexternals' in rc: extdata = rc['.hgsvnexternals'].data() assert '[.]' not in extdata print extdata expect = '' # Not honestly sure what this should be... test = 4 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)