##// END OF EJS Templates
run-tests: move test discovery logic into a function...
Gregory Szorc -
r21363:00e5f5b9 default
parent child Browse files
Show More
@@ -1026,6 +1026,25 b' class TestRunner(object):'
1026 self.abort = [False]
1026 self.abort = [False]
1027 self._createdfiles = []
1027 self._createdfiles = []
1028
1028
1029 def findtests(self, args):
1030 """Finds possible test files from arguments.
1031
1032 If you wish to inject custom tests into the test harness, this would
1033 be a good function to monkeypatch or override in a derived class.
1034 """
1035 if not args:
1036 if self.options.changed:
1037 proc = Popen4('hg st --rev "%s" -man0 .' %
1038 self.options.changed, None, 0)
1039 stdout, stderr = proc.communicate()
1040 args = stdout.strip('\0').split('\0')
1041 else:
1042 args = os.listdir('.')
1043
1044 return [t for t in args
1045 if os.path.basename(t).startswith('test-')
1046 and (t.endswith('.py') or t.endswith('.t'))]
1047
1029 def runtests(self, tests):
1048 def runtests(self, tests):
1030 try:
1049 try:
1031 if self.inst:
1050 if self.inst:
@@ -1322,18 +1341,7 b' def main(args, parser=None):'
1322
1341
1323 checktools()
1342 checktools()
1324
1343
1325 if not args:
1344 tests = runner.findtests(args)
1326 if options.changed:
1327 proc = Popen4('hg st --rev "%s" -man0 .' % options.changed,
1328 None, 0)
1329 stdout, stderr = proc.communicate()
1330 args = stdout.strip('\0').split('\0')
1331 else:
1332 args = os.listdir(".")
1333
1334 tests = [t for t in args
1335 if os.path.basename(t).startswith("test-")
1336 and (t.endswith(".py") or t.endswith(".t"))]
1337
1345
1338 if options.random:
1346 if options.random:
1339 random.shuffle(tests)
1347 random.shuffle(tests)
General Comments 0
You need to be logged in to leave comments. Login now