run-tests: pass temp dir into Test.__init__
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 22 Apr 2014 10:05:32 -0700
changeset 21504 888a5dfe1569
parent 21503 10f15e34d86c
child 21505 3a1881dbf860
run-tests: pass temp dir into Test.__init__ This patch starts a mini series of moving arguments to Test.__init__ from semi-complex data structures (such as the command options) to named arguments. This will allow Test instances to be more easily instantiated from other contexts. This improves the ability to run Mercurial tests in new and different environments.
tests/run-tests.py
--- a/tests/run-tests.py	Thu Mar 07 14:17:56 2013 +1100
+++ b/tests/run-tests.py	Tue Apr 22 10:05:32 2014 -0700
@@ -338,7 +338,7 @@
     # Status code reserved for skipped tests (used by hghave).
     SKIPPED_STATUS = 80
 
-    def __init__(self, runner, path, count):
+    def __init__(self, runner, path, count, tmpdir):
         """Create a test from parameters.
 
         runner is a TestRunner instance.
@@ -346,6 +346,8 @@
         path is the full path to the file defining the test.
 
         count is an identifier used to denote this test instance.
+
+        tmpdir is the main temporary directory to use for this test.
         """
 
         self._path = path
@@ -356,6 +358,7 @@
         self._runner = runner
         self._options = runner.options
         self._count = count
+        self._threadtmp = tmpdir
         self._daemonpids = []
 
         self._finished = None
@@ -375,8 +378,6 @@
         else:
             self._refout = []
 
-        self._threadtmp = os.path.join(runner.hgtmp, 'child%d' % count)
-
     def __str__(self):
         return self.name
 
@@ -1467,7 +1468,10 @@
                 testcls = cls
                 break
 
-        return testcls(self, os.path.join(self.testdir, test), count)
+        refpath = os.path.join(self.testdir, test)
+        tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
+
+        return testcls(self, refpath, count, tmpdir)
 
     def _cleanup(self):
         """Clean up state from this test invocation."""