Comments
Patch
@@ -1019,16 +1019,35 @@ class TestRunner(object):
'!': [],
'~': [],
's': [],
'i': [],
}
self.abort = [False]
self._createdfiles = []
+ def findtests(self, args):
+ """Finds possible test files from arguments.
+
+ If you wish to inject custom tests into the test harness, this would
+ be a good function to monkeypatch or override in a derived class.
+ """
+ if not args:
+ if self.options.changed:
+ proc = Popen4('hg st --rev "%s" -man0 .' %
+ self.options.changed, None, 0)
+ stdout, stderr = proc.communicate()
+ args = stdout.strip('\0').split('\0')
+ else:
+ args = os.listdir('.')
+
+ return [t for t in args
+ if os.path.basename(t).startswith('test-')
+ and (t.endswith('.py') or t.endswith('.t'))]
+
def runtests(self, tests):
try:
if self.inst:
self.installhg()
self.checkhglib("Testing")
else:
self.usecorrectpython()
@@ -1315,28 +1334,17 @@ def main(args, parser=None):
parser = parser or getparser()
(options, args) = parseargs(args, parser)
runner.options = options
os.umask(022)
checktools()
- if not args:
- if options.changed:
- proc = Popen4('hg st --rev "%s" -man0 .' % options.changed,
- None, 0)
- stdout, stderr = proc.communicate()
- args = stdout.strip('\0').split('\0')
- else:
- args = os.listdir(".")
-
- tests = [t for t in args
- if os.path.basename(t).startswith("test-")
- and (t.endswith(".py") or t.endswith(".t"))]
+ tests = runner.findtests(args)
if options.random:
random.shuffle(tests)
else:
# keywords for slow tests
slow = 'svn gendoc check-code-hg'.split()
def sortkey(f):
# run largest tests first, as they tend to take the longest