comparison tests/run-tests.py @ 21509:d21d53ee0d7a

run-tests: factor options.keep_tmpdir into an argument to Test.__init__
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 22 Apr 2014 11:41:10 -0700
parents 4cc3aaa3a2ee
children 97127c4ce460
comparison
equal deleted inserted replaced
21508:4cc3aaa3a2ee 21509:d21d53ee0d7a
336 """ 336 """
337 337
338 # Status code reserved for skipped tests (used by hghave). 338 # Status code reserved for skipped tests (used by hghave).
339 SKIPPED_STATUS = 80 339 SKIPPED_STATUS = 80
340 340
341 def __init__(self, options, path, count, tmpdir, abort): 341 def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False):
342 """Create a test from parameters. 342 """Create a test from parameters.
343 343
344 options are parsed command line options that control test execution. 344 options are parsed command line options that control test execution.
345 345
346 path is the full path to the file defining the test. 346 path is the full path to the file defining the test.
349 349
350 tmpdir is the main temporary directory to use for this test. 350 tmpdir is the main temporary directory to use for this test.
351 351
352 abort is a flag that turns to True if test execution should be aborted. 352 abort is a flag that turns to True if test execution should be aborted.
353 It is consulted periodically during the execution of tests. 353 It is consulted periodically during the execution of tests.
354
355 keeptmpdir determines whether to keep the test's temporary directory
356 after execution. It defaults to removal (False).
354 """ 357 """
355 358
356 self.path = path 359 self.path = path
357 self.name = os.path.basename(path) 360 self.name = os.path.basename(path)
358 self._testdir = os.path.dirname(path) 361 self._testdir = os.path.dirname(path)
360 363
361 self._options = options 364 self._options = options
362 self._count = count 365 self._count = count
363 self._threadtmp = tmpdir 366 self._threadtmp = tmpdir
364 self._abort = abort 367 self._abort = abort
368 self._keeptmpdir = keeptmpdir
365 self._daemonpids = [] 369 self._daemonpids = []
366 370
367 self._finished = None 371 self._finished = None
368 self._ret = None 372 self._ret = None
369 self._out = None 373 self._out = None
535 """Tasks to perform after run().""" 539 """Tasks to perform after run()."""
536 for entry in self._daemonpids: 540 for entry in self._daemonpids:
537 killdaemons(entry) 541 killdaemons(entry)
538 self._daemonpids = [] 542 self._daemonpids = []
539 543
540 if not self._options.keep_tmpdir: 544 if not self._keeptmpdir:
541 shutil.rmtree(self._testtmp, True) 545 shutil.rmtree(self._testtmp, True)
542 shutil.rmtree(self._threadtmp, True) 546 shutil.rmtree(self._threadtmp, True)
543 547
544 if (self._ret != 0 or self._out != self._refout) and not self._skipped \ 548 if (self._ret != 0 or self._out != self._refout) and not self._skipped \
545 and not self._options.debug and self._out: 549 and not self._options.debug and self._out:
1483 break 1487 break
1484 1488
1485 refpath = os.path.join(self.testdir, test) 1489 refpath = os.path.join(self.testdir, test)
1486 tmpdir = os.path.join(self.hgtmp, 'child%d' % count) 1490 tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
1487 1491
1488 return testcls(self.options, refpath, count, tmpdir, self.abort) 1492 return testcls(self.options, refpath, count, tmpdir, self.abort,
1493 keeptmpdir=self.options.keep_tmpdir)
1489 1494
1490 def _cleanup(self): 1495 def _cleanup(self):
1491 """Clean up state from this test invocation.""" 1496 """Clean up state from this test invocation."""
1492 1497
1493 if self.options.keep_tmpdir: 1498 if self.options.keep_tmpdir: