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.
--- 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."""