Mercurial > hgsubversion
comparison tests/test_util.py @ 872:a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
This solves a problem with startrev tests sporadically failing in ra.get_log()
with some kind of svn corruption error. Loading each svn repository in a
different place solved that, or at least prevented me from reproducing it. What
is interesting is this is the same fixture being loaded each time. Also, before
loading the fixture, we take care of removing an existing repository. Loading
with the same options twice also failed reproducing the issue. Same thing if
the first load only load the svn repository but does not convert it.
So, I have absolutely no idea what was wrong, blame python subprocess,
subversion or some kind of filesystem write ordering bug.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Thu, 19 Apr 2012 18:29:32 +0200 |
parents | 51fd75ae62b9 |
children | f2de043ac924 |
comparison
equal
deleted
inserted
replaced
871:51fd75ae62b9 | 872:a279b5838aaf |
---|---|
250 os.environ['HGRCPATH'] = self.hgrc | 250 os.environ['HGRCPATH'] = self.hgrc |
251 rc = open(self.hgrc, 'w') | 251 rc = open(self.hgrc, 'w') |
252 for l in '[extensions]', 'hgsubversion=': | 252 for l in '[extensions]', 'hgsubversion=': |
253 print >> rc, l | 253 print >> rc, l |
254 | 254 |
255 self.repo_path = '%s/testrepo' % self.tmpdir | 255 self.repocount = 0 |
256 self.wc_path = '%s/testrepo_wc' % self.tmpdir | 256 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
257 self.svn_wc = None | 257 self.svn_wc = None |
258 | 258 |
259 # Previously, we had a MockUI class that wrapped ui, and giving access | 259 # Previously, we had a MockUI class that wrapped ui, and giving access |
260 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used | 260 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used |
261 # instead. Using the regular UI class, with all stderr redirected to | 261 # instead. Using the regular UI class, with all stderr redirected to |
262 # stdout ensures that the test setup is much more similar to usage | 262 # stdout ensures that the test setup is much more similar to usage |
263 # setups. | 263 # setups. |
264 self.patch = (ui.ui.write_err, ui.ui.write) | 264 self.patch = (ui.ui.write_err, ui.ui.write) |
265 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) | 265 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) |
266 | |
267 def _makerepopath(self): | |
268 self.repocount += 1 | |
269 return '%s/testrepo-%d' % (self.tmpdir, self.repocount) | |
266 | 270 |
267 def tearDown(self): | 271 def tearDown(self): |
268 for var, val in self.oldenv.iteritems(): | 272 for var, val in self.oldenv.iteritems(): |
269 if val is None: | 273 if val is None: |
270 del os.environ[var] | 274 del os.environ[var] |
282 | 286 |
283 def load_svndump(self, fixture_name): | 287 def load_svndump(self, fixture_name): |
284 '''Loads an svnadmin dump into a fresh repo. Return the svn repo | 288 '''Loads an svnadmin dump into a fresh repo. Return the svn repo |
285 path. | 289 path. |
286 ''' | 290 ''' |
287 path = self.repo_path | 291 path = self._makerepopath() |
288 if os.path.exists(path): | 292 assert not os.path.exists(path) |
289 rmtree(path) | |
290 subprocess.call(['svnadmin', 'create', path,], | 293 subprocess.call(['svnadmin', 'create', path,], |
291 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 294 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
292 inp = open(os.path.join(FIXTURES, fixture_name)) | 295 inp = open(os.path.join(FIXTURES, fixture_name)) |
293 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, | 296 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, |
294 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 297 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |