run-tests: factor options.keep_tmpdir into an argument to Test.__init__
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 22 Apr 2014 11:41:10 -0700
changeset 21509 d21d53ee0d7a
parent 21508 4cc3aaa3a2ee
child 21510 97127c4ce460
run-tests: factor options.keep_tmpdir into an argument to Test.__init__
tests/run-tests.py
--- a/tests/run-tests.py	Tue Apr 22 12:29:33 2014 -0700
+++ b/tests/run-tests.py	Tue Apr 22 11:41:10 2014 -0700
@@ -338,7 +338,7 @@
     # Status code reserved for skipped tests (used by hghave).
     SKIPPED_STATUS = 80
 
-    def __init__(self, options, path, count, tmpdir, abort):
+    def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False):
         """Create a test from parameters.
 
         options are parsed command line options that control test execution.
@@ -351,6 +351,9 @@
 
         abort is a flag that turns to True if test execution should be aborted.
         It is consulted periodically during the execution of tests.
+
+        keeptmpdir determines whether to keep the test's temporary directory
+        after execution. It defaults to removal (False).
         """
 
         self.path = path
@@ -362,6 +365,7 @@
         self._count = count
         self._threadtmp = tmpdir
         self._abort = abort
+        self._keeptmpdir = keeptmpdir
         self._daemonpids = []
 
         self._finished = None
@@ -537,7 +541,7 @@
             killdaemons(entry)
         self._daemonpids = []
 
-        if not self._options.keep_tmpdir:
+        if not self._keeptmpdir:
             shutil.rmtree(self._testtmp, True)
             shutil.rmtree(self._threadtmp, True)
 
@@ -1485,7 +1489,8 @@
         refpath = os.path.join(self.testdir, test)
         tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
 
-        return testcls(self.options, refpath, count, tmpdir, self.abort)
+        return testcls(self.options, refpath, count, tmpdir, self.abort,
+                       keeptmpdir=self.options.keep_tmpdir)
 
     def _cleanup(self):
         """Clean up state from this test invocation."""