comparison tests/comprehensive/test_verify_and_startrev.py @ 886:d3ff5807f1bd

fold test_startrev and test_verify into a new test; test_verify_and_startrev
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 12 May 2012 11:12:57 +0200
parents tests/comprehensive/test_verify.py@312b37bc5e20
children c6388ed0ec0a
comparison
equal deleted inserted replaced
885:99a15c6a283c 886:d3ff5807f1bd
1 import os
2 import pickle
3 import sys
4 import unittest
5
6 # wrapped in a try/except because of weirdness in how
7 # run.py works as compared to nose.
8 try:
9 import test_util
10 except ImportError:
11 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
12 import test_util
13
14 from mercurial import hg
15 from mercurial import ui
16
17 from hgsubversion import svncommands
18
19 # these fixtures contain no files at HEAD and would result in empty clones
20 _skipshallow = set([
21 'binaryfiles.svndump',
22 'binaryfiles-broken.svndump',
23 'emptyrepo.svndump',
24 ])
25
26 def _do_case(self, name, stupid, layout):
27 subdir = test_util.subdir.get(name, '')
28 repo, svnpath = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
29 layout=layout)
30 assert len(self.repo) > 0
31 for i in repo:
32 ctx = repo[i]
33 self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0)
34
35 # check a startrev clone
36 if layout == 'single' and name not in _skipshallow:
37 self.wc_path += '_shallow'
38 shallowrepo = self.fetch(svnpath, subdir=subdir, stupid=stupid,
39 layout='single', startrev='HEAD')
40
41 self.assertEqual(len(shallowrepo), 1,
42 "shallow clone should have just one revision, not %d"
43 % len(shallowrepo))
44
45 fulltip = repo['tip']
46 shallowtip = shallowrepo['tip']
47
48 self.assertEqual(0, svncommands.verify(repo.ui, shallowrepo,
49 rev=shallowtip.node()))
50
51 # viewing diff's of lists of files is easier on the eyes
52 self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip))
53
54 for f in fulltip:
55 self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
56
57
58 def buildmethod(case, name, stupid, layout):
59 m = lambda self: self._do_case(case, stupid, layout)
60 m.__name__ = name
61 bits = case, stupid and 'stupid' or 'real', layout
62 m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits
63 return m
64
65 attrs = {'_do_case': _do_case}
66 fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
67 for case in fixtures:
68 # this fixture results in an empty repository, don't use it
69 if case == 'project_root_not_repo_root.svndump':
70 continue
71 bname = 'test_' + case[:-len('.svndump')]
72 attrs[bname] = buildmethod(case, bname, False, 'standard')
73 name = bname + '_stupid'
74 attrs[name] = buildmethod(case, name, True, 'standard')
75 name = bname + '_single'
76 attrs[name] = buildmethod(case, name, False, 'single')
77 # Disabled because the "stupid and real are the same" tests
78 # verify this plus even more.
79 # name = bname + '_single_stupid'
80 # attrs[name] = buildmethod(case, name, True, 'single')
81
82 VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)
83
84 def suite():
85 all_tests = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)]
86 return unittest.TestSuite(all_tests)