annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
1 import os
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
2 import pickle
766
124cd25de4ef tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
3 import sys
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
4 import unittest
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
5
426
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
6 # wrapped in a try/except because of weirdness in how
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
7 # run.py works as compared to nose.
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
8 try:
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
9 import test_util
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
10 except ImportError:
766
124cd25de4ef tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
11 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
124cd25de4ef tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
12 import test_util
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
13
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
14 from mercurial import hg
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
15 from mercurial import ui
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
16
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
17 from hgsubversion import svncommands
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
18
886
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
19 # these fixtures contain no files at HEAD and would result in empty clones
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
20 _skipshallow = set([
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
21 'binaryfiles.svndump',
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
22 'binaryfiles-broken.svndump',
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
23 'emptyrepo.svndump',
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
24 ])
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
25
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
26 def _do_case(self, name, stupid, layout):
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
27 subdir = test_util.subdir.get(name, '')
886
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
28 repo, svnpath = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
29 layout=layout)
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
30 assert len(self.repo) > 0
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
31 for i in repo:
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
32 ctx = repo[i]
441
de085126dbd4 svncommands: use rev instead of verifynode -- should not have to be a node
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 427
diff changeset
33 self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0)
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
34
886
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
35 # check a startrev clone
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
36 if layout == 'single' and name not in _skipshallow:
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
37 self.wc_path += '_shallow'
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
38 shallowrepo = self.fetch(svnpath, subdir=subdir, stupid=stupid,
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
39 layout='single', startrev='HEAD')
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
40
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
41 self.assertEqual(len(shallowrepo), 1,
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
42 "shallow clone should have just one revision, not %d"
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
43 % len(shallowrepo))
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
44
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
45 fulltip = repo['tip']
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
46 shallowtip = shallowrepo['tip']
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
47
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
48 self.assertEqual(0, svncommands.verify(repo.ui, shallowrepo,
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
49 rev=shallowtip.node()))
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
50
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
51 # viewing diff's of lists of files is easier on the eyes
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
52 self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip))
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
53
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
54 for f in fulltip:
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
55 self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
56
d3ff5807f1bd fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 833
diff changeset
57
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
58 def buildmethod(case, name, stupid, layout):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
59 m = lambda self: self._do_case(case, stupid, layout)
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
60 m.__name__ = name
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
61 bits = case, stupid and 'stupid' or 'real', layout
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
62 m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
63 return m
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
64
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
65 attrs = {'_do_case': _do_case}
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
66 fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
67 for case in fixtures:
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
68 # this fixture results in an empty repository, don't use it
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
69 if case == 'project_root_not_repo_root.svndump':
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
70 continue
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
71 bname = 'test_' + case[:-len('.svndump')]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
72 attrs[bname] = buildmethod(case, bname, False, 'standard')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
73 name = bname + '_stupid'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
74 attrs[name] = buildmethod(case, name, True, 'standard')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
75 name = bname + '_single'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
76 attrs[name] = buildmethod(case, name, False, 'single')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
77 # Disabled because the "stupid and real are the same" tests
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
78 # verify this plus even more.
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
79 # name = bname + '_single_stupid'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 441
diff changeset
80 # attrs[name] = buildmethod(case, name, True, 'single')
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
81
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
82 VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
83
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
84 def suite():
833
312b37bc5e20 tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents: 766
diff changeset
85 all_tests = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)]
312b37bc5e20 tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents: 766
diff changeset
86 return unittest.TestSuite(all_tests)