annotate tests/comprehensive/test_updatemeta.py @ 1044:d741f536f23a

tests: remove old test-loading infrastructure (for those in the know, this is known as a suitectomy)
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 07 Aug 2013 16:00:52 +0200
parents af84ef787d93
children 903c9c9dfe6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
1 import os
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
2 import pickle
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
3 import unittest
1042
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
4
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
5 # wrapped in a try/except because of weirdness in how
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
6 # run.py works as compared to nose.
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
7 try:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
8 import test_util
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
9 except ImportError:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
10 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
11 import test_util
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 930
diff changeset
12
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
13 import test_rebuildmeta
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
14
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
15 from mercurial import context
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
16 from mercurial import extensions
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
17 from mercurial import hg
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
18 from mercurial import ui
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
19
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
20 from hgsubversion import svncommands
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
21 from hgsubversion import svnmeta
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
22
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
23
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
24
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
25 def _do_case(self, name, stupid, single):
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
26 subdir = test_util.subdir.get(name, '')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
27 layout = 'auto'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
28 if single:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
29 layout = 'single'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
30 repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
31 layout=layout)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
32 assert len(self.repo) > 0
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
33 wc2_path = self.wc_path + '_clone'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
34 u = ui.ui()
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
35 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False)
930
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
36 src = test_util.getlocalpeer(src)
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
37 dest = test_util.getlocalpeer(dest)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
38
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
39 # insert a wrapper that prevents calling changectx.children()
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
40 def failfn(orig, ctx):
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
41 self.fail('calling %s is forbidden; it can cause massive slowdowns '
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
42 'when rebuilding large repositories' % orig)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
43
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
44 origchildren = getattr(context.changectx, 'children')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
45 extensions.wrapfunction(context.changectx, 'children', failfn)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
46
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
47 # test updatemeta on an empty repo
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
48 try:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
49 svncommands.updatemeta(u, dest,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
50 args=[test_util.fileurl(repo_path +
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
51 subdir), ])
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
52 finally:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
53 # remove the wrapper
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
54 context.changectx.children = origchildren
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
55
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
56 self._run_assertions(name, stupid, single, src, dest, u)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
57
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
58
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
59 def _run_assertions(self, name, stupid, single, src, dest, u):
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
60 test_rebuildmeta._run_assertions(self, name, stupid, single, src, dest, u)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
61
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
62
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
63 skip = set([
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
64 'project_root_not_repo_root.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
65 'corrupt.svndump',
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
66 ])
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
67
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
68 attrs = {'_do_case': _do_case,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
69 '_run_assertions': _run_assertions,
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
70 }
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
71 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
72 # this fixture results in an empty repository, don't use it
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
73 if case in skip:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
74 continue
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
75 bname = 'test_' + case[:-len('.svndump')]
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
76 attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False, False)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
77 name = bname + '_stupid'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
78 attrs[name] = test_rebuildmeta.buildmethod(case, name, True, False)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
79 name = bname + '_single'
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
80 attrs[name] = test_rebuildmeta.buildmethod(case, name, False, True)
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
81
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents:
diff changeset
82 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs)