# HG changeset patch # User Gregory Szorc # Date 2014-04-22 17:05:32 # Node ID 888a5dfe1569dee19ee136399f3aa9e0722d9fec # Parent 10f15e34d86c57909ee58484ca9dc2b82053c399 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. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -338,7 +338,7 @@ class Test(unittest.TestCase): # 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 @@ class Test(unittest.TestCase): 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 @@ class Test(unittest.TestCase): self._runner = runner self._options = runner.options self._count = count + self._threadtmp = tmpdir self._daemonpids = [] self._finished = None @@ -375,8 +378,6 @@ class Test(unittest.TestCase): else: self._refout = [] - self._threadtmp = os.path.join(runner.hgtmp, 'child%d' % count) - def __str__(self): return self.name @@ -1467,7 +1468,10 @@ class TestRunner(object): 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."""