##// END OF EJS Templates
run-tests: refactor temporary directories in Test...
Gregory Szorc -
r21497:798c81e3 default
parent child Browse files
Show More
@@ -330,8 +330,9 b' def killdaemons(pidfile):'
330 class Test(unittest.TestCase):
330 class Test(unittest.TestCase):
331 """Encapsulates a single, runnable test.
331 """Encapsulates a single, runnable test.
332
332
333 Test instances can be run multiple times via run(). However, multiple
333 While this class conforms to the unittest.TestCase API, it differs in that
334 runs cannot be run concurrently.
334 instances need to be instantiated manually. (Typically, unittest.TestCase
335 classes are instantiated automatically by scanning modules.)
335 """
336 """
336
337
337 # Status code reserved for skipped tests (used by hghave).
338 # Status code reserved for skipped tests (used by hghave).
@@ -370,16 +371,6 b' class Test(unittest.TestCase):'
370 self._refout = []
371 self._refout = []
371
372
372 self._threadtmp = os.path.join(runner.hgtmp, 'child%d' % count)
373 self._threadtmp = os.path.join(runner.hgtmp, 'child%d' % count)
373 os.mkdir(self._threadtmp)
374
375 def cleanup(self):
376 for entry in self._daemonpids:
377 killdaemons(entry)
378
379 if self._threadtmp and not self._options.keep_tmpdir:
380 # Ignore failures here. The rmtree() in the higher level runner
381 # will try again.
382 shutil.rmtree(self._threadtmp, True)
383
374
384 def __str__(self):
375 def __str__(self):
385 return self.name
376 return self.name
@@ -394,6 +385,12 b' class Test(unittest.TestCase):'
394 self._out = None
385 self._out = None
395 self._skipped = None
386 self._skipped = None
396
387
388 try:
389 os.mkdir(self._threadtmp)
390 except OSError, e:
391 if e.errno != errno.EEXIST:
392 raise
393
397 self._testtmp = os.path.join(self._threadtmp,
394 self._testtmp = os.path.join(self._threadtmp,
398 os.path.basename(self._path))
395 os.path.basename(self._path))
399 os.mkdir(self._testtmp)
396 os.mkdir(self._testtmp)
@@ -560,6 +557,7 b' class Test(unittest.TestCase):'
560
557
561 if not self._options.keep_tmpdir:
558 if not self._options.keep_tmpdir:
562 shutil.rmtree(self._testtmp, True)
559 shutil.rmtree(self._testtmp, True)
560 shutil.rmtree(self._threadtmp, True)
563
561
564 if (self._ret != 0 or self._out != self._refout) and not self._skipped \
562 if (self._ret != 0 or self._out != self._refout) and not self._skipped \
565 and not self._options.debug and self._out:
563 and not self._options.debug and self._out:
General Comments 0
You need to be logged in to leave comments. Login now