comparison tests/test_utility_commands.py @ 892:3bfb7e985c47

svn verify: add a test for corrupt repositories. This case contains a couple of unlikely (but not impossible) failure cases that the code previously did not handle. The verifier is updated to address these, and the output made a bit more consistent.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 14 Dec 2011 00:07:58 +0100
parents f95c429124f3
children 6bc8046e3d0a
comparison
equal deleted inserted replaced
889:7a98fbadcae9 892:3bfb7e985c47
258 output = u.popbuffer() 258 output = u.popbuffer()
259 self.assertEqual(1, ret) 259 self.assertEqual(1, ret)
260 output = re.sub(r'file://\S+', 'file://', output) 260 output = re.sub(r'file://\S+', 'file://', output)
261 self.assertMultiLineEqual("""\ 261 self.assertMultiLineEqual("""\
262 verifying d51f46a715a1 against file:// 262 verifying d51f46a715a1 against file://
263 difference in file binary2 263 difference in: binary2
264 unexpected files: 264 unexpected file: binary1
265 binary1 265 missing file: binary3
266 missing files:
267 binary3
268 """, output) 266 """, output)
267
268 def test_svnverify_corruption(self):
269 SUCCESS = 0
270 FAILURE = 1
271
272 repo, repo_path = self.load_and_fetch('correct.svndump', layout='single',
273 subdir='')
274
275 ui = self.ui()
276
277 self.assertEqual(SUCCESS, svncommands.verify(ui, self.repo, rev='tip'))
278
279 corrupt_source = test_util.fileurl(self.load_svndump('corrupt.svndump'))
280
281 repo.ui.setconfig('paths', 'default', corrupt_source)
282
283 ui.pushbuffer()
284 code = svncommands.verify(ui, repo, rev='tip')
285 actual = ui.popbuffer()
286
287 actual = actual.replace(corrupt_source, '$REPO')
288 actual = set(actual.splitlines())
289
290 expected = set([
291 'verifying 78e965230a13 against $REPO@1',
292 'missing file: missing-file',
293 'wrong flags for: executable-file',
294 'wrong flags for: symlink',
295 'wrong flags for: regular-file',
296 'difference in: another-regular-file',
297 'difference in: regular-file',
298 'unexpected file: empty-file',
299 ])
300
301 self.assertEqual((FAILURE, expected), (code, actual))
269 302
270 def suite(): 303 def suite():
271 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), 304 all_tests = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests),
272 ] 305 ]
273 return unittest.TestSuite(all_tests) 306 return unittest.TestSuite(all_tests)