Mercurial > hgsubversion
comparison tests/comprehensive/test_rebuildmeta.py @ 1057:cd256960b622
comprehensive tests: consolidate stupidity into test_util
In other words, remove explicit 'stupid' arguments, set the
'stupid_mode_tests' class variable, and have the metaclass generate
non-replay tests.
| author | Dan Villiom Podlaski Christiansen <dan@cabo.dk> |
|---|---|
| date | Wed, 07 Aug 2013 23:31:57 +0200 |
| parents | 903c9c9dfe6a |
| children | cd0d14e25757 |
comparison
equal
deleted
inserted
replaced
| 1056:0932bb4d8870 | 1057:cd256960b622 |
|---|---|
| 28 ('unrelatedbranch.svndump', True, False), | 28 ('unrelatedbranch.svndump', True, False), |
| 29 ] | 29 ] |
| 30 | 30 |
| 31 | 31 |
| 32 | 32 |
| 33 def _do_case(self, name, stupid, single): | 33 def _do_case(self, name, single): |
| 34 subdir = test_util.subdir.get(name, '') | 34 subdir = test_util.subdir.get(name, '') |
| 35 layout = 'auto' | 35 layout = 'auto' |
| 36 if single: | 36 if single: |
| 37 layout = 'single' | 37 layout = 'single' |
| 38 repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid, | 38 repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout) |
| 39 layout=layout) | |
| 40 assert test_util.repolen(self.repo) > 0 | 39 assert test_util.repolen(self.repo) > 0 |
| 41 wc2_path = self.wc_path + '_clone' | 40 wc2_path = self.wc_path + '_clone' |
| 42 u = ui.ui() | 41 u = ui.ui() |
| 43 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) | 42 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False) |
| 44 src = test_util.getlocalpeer(src) | 43 src = test_util.getlocalpeer(src) |
| 58 subdir), ]) | 57 subdir), ]) |
| 59 finally: | 58 finally: |
| 60 # remove the wrapper | 59 # remove the wrapper |
| 61 context.changectx.children = origchildren | 60 context.changectx.children = origchildren |
| 62 | 61 |
| 63 self._run_assertions(name, stupid, single, src, dest, u) | 62 self._run_assertions(name, single, src, dest, u) |
| 64 | 63 |
| 65 wc3_path = self.wc_path + '_partial' | 64 wc3_path = self.wc_path + '_partial' |
| 66 src, dest = test_util.hgclone(u, | 65 src, dest = test_util.hgclone(u, |
| 67 self.wc_path, | 66 self.wc_path, |
| 68 wc3_path, | 67 wc3_path, |
| 92 subdir), ]) | 91 subdir), ]) |
| 93 finally: | 92 finally: |
| 94 # remove the wrapper | 93 # remove the wrapper |
| 95 context.changectx.children = origchildren | 94 context.changectx.children = origchildren |
| 96 | 95 |
| 97 self._run_assertions(name, stupid, single, srcrepo, dest, u) | 96 self._run_assertions(name, single, srcrepo, dest, u) |
| 98 | 97 |
| 99 | 98 |
| 100 def _run_assertions(self, name, stupid, single, src, dest, u): | 99 def _run_assertions(self, name, single, src, dest, u): |
| 101 | 100 |
| 102 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), | 101 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')), |
| 103 'no .hg/svn directory in the source!') | 102 'no .hg/svn directory in the source!') |
| 104 self.assertTrue(os.path.isdir(os.path.join(dest.path, 'svn')), | 103 self.assertTrue(os.path.isdir(os.path.join(dest.path, 'svn')), |
| 105 'no .hg/svn directory in the destination!') | 104 'no .hg/svn directory in the destination!') |
| 110 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf) | 109 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf) |
| 111 dtf = os.path.join(dest.path, 'svn', tf) | 110 dtf = os.path.join(dest.path, 'svn', tf) |
| 112 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) | 111 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) |
| 113 old, new = open(stf).read(), open(dtf).read() | 112 old, new = open(stf).read(), open(dtf).read() |
| 114 if tf == 'lastpulled' and (name, | 113 if tf == 'lastpulled' and (name, |
| 115 stupid, single) in expect_youngest_skew: | 114 self.stupid, single) in expect_youngest_skew: |
| 116 self.assertNotEqual(old, new, | 115 self.assertNotEqual(old, new, |
| 117 'rebuildmeta unexpected match on youngest rev!') | 116 'rebuildmeta unexpected match on youngest rev!') |
| 118 continue | 117 continue |
| 119 self.assertMultiLineEqual(old, new, tf + ' differs') | 118 self.assertMultiLineEqual(old, new, tf + ' differs') |
| 120 self.assertEqual(src.branchtags(), dest.branchtags()) | 119 self.assertEqual(src.branchtags(), dest.branchtags()) |
| 135 revkeys), reverse=True)[0][0] | 134 revkeys), reverse=True)[0][0] |
| 136 self.assertEqual(pr, destinfo[1]) | 135 self.assertEqual(pr, destinfo[1]) |
| 137 self.assertEqual(srcinfo[2], destinfo[2]) | 136 self.assertEqual(srcinfo[2], destinfo[2]) |
| 138 | 137 |
| 139 | 138 |
| 140 def buildmethod(case, name, stupid, single): | 139 def buildmethod(case, name, single): |
| 141 m = lambda self: self._do_case(case, stupid, single) | 140 m = lambda self: self._do_case(case, single) |
| 142 m.__name__ = name | 141 m.__name__ = name |
| 143 m.__doc__ = ('Test rebuildmeta on %s with %s replay. (%s)' % | 142 m.__doc__ = ('Test rebuildmeta on %s (%s)' % |
| 144 (case, | 143 (case, (single and 'single') or 'standard')) |
| 145 (stupid and 'stupid') or 'real', | |
| 146 (single and 'single') or 'standard', | |
| 147 ) | |
| 148 ) | |
| 149 return m | 144 return m |
| 150 | 145 |
| 151 | 146 |
| 152 skip = set([ | 147 skip = set([ |
| 153 'project_root_not_repo_root.svndump', | 148 'project_root_not_repo_root.svndump', |
| 154 'corrupt.svndump', | 149 'corrupt.svndump', |
| 155 ]) | 150 ]) |
| 156 | 151 |
| 157 attrs = {'_do_case': _do_case, | 152 attrs = {'_do_case': _do_case, |
| 158 '_run_assertions': _run_assertions, | 153 '_run_assertions': _run_assertions, |
| 154 'stupid_mode_tests': True, | |
| 159 } | 155 } |
| 160 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: | 156 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: |
| 161 # this fixture results in an empty repository, don't use it | 157 # this fixture results in an empty repository, don't use it |
| 162 if case in skip: | 158 if case in skip: |
| 163 continue | 159 continue |
| 164 bname = 'test_' + case[:-len('.svndump')] | 160 bname = 'test_' + case[:-len('.svndump')] |
| 165 attrs[bname] = buildmethod(case, bname, False, False) | 161 attrs[bname] = buildmethod(case, bname, False) |
| 166 name = bname + '_stupid' | |
| 167 attrs[name] = buildmethod(case, name, True, False) | |
| 168 name = bname + '_single' | 162 name = bname + '_single' |
| 169 attrs[name] = buildmethod(case, name, False, True) | 163 attrs[name] = buildmethod(case, name, True) |
| 170 | 164 |
| 171 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs) | 165 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs) |
