# HG changeset patch # User Gregory Szorc # Date 2014-04-22 17:01:22 # Node ID f8515564d617e6e194f4284f4ebae9b1ca23ce2b # Parent 98a0c58ee2007bcc8725c86035d3a282d325ca57 run-tests: pass a full test path into Test.__init__ Previously, a Test's path came from the base directory of all tests and a filename leaf. There is not a strong reason why an absolute test path can not be specified. This change isn't strictly necessary. But it does enable scenarios such as more easily running tests from multiple, non-sibling directories. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -338,19 +338,25 @@ class Test(unittest.TestCase): # Status code reserved for skipped tests (used by hghave). SKIPPED_STATUS = 80 - def __init__(self, runner, test, count): - path = os.path.join(runner.testdir, test) - errpath = os.path.join(runner.testdir, '%s.err' % test) + def __init__(self, runner, path, count): + """Create a test from parameters. + + runner is a TestRunner instance. + + path is the full path to the file defining the test. - self.name = test + count is an identifier used to denote this test instance. + """ + + self._path = path + self.name = os.path.basename(path) + self._testdir = os.path.dirname(path) + self._errpath = os.path.join(self._testdir, '%s.err' % self.name) self._runner = runner - self._testdir = runner.testdir - self._path = path self._options = runner.options self._count = count self._daemonpids = [] - self._errpath = errpath self._finished = None self._ret = None @@ -1461,7 +1467,7 @@ class TestRunner(object): testcls = cls break - return testcls(self, test, count) + return testcls(self, os.path.join(self.testdir, test), count) def _cleanup(self): """Clean up state from this test invocation."""