changeset 21502:f8515564d617

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 22 Apr 2014 10:01:22 -0700
parents 98a0c58ee200
children 10f15e34d86c
files tests/run-tests.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Mon Apr 21 16:43:36 2014 -0700
+++ b/tests/run-tests.py	Tue Apr 22 10:01:22 2014 -0700
@@ -338,19 +338,25 @@
     # 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 @@
                 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."""