##// END OF EJS Templates
run-tests: refactor runone() into gettest() and scheduletests()...
Gregory Szorc -
r21339:de25e968 default
parent child Browse files
Show More
@@ -708,7 +708,8 b' class Test(object):'
708 return res
708 return res
709
709
710 def _run(self, testtmp, replacements, env):
710 def _run(self, testtmp, replacements, env):
711 raise NotImplemented('Subclasses must implement Test.run()')
711 # This should be implemented in child classes to run tests.
712 return self._skip('unknown test type')
712
713
713 def _getreplacements(self, testtmp):
714 def _getreplacements(self, testtmp):
714 port = self._options.port + self._count * 3
715 port = self._options.port + self._count * 3
@@ -1083,6 +1084,26 b' class TTest(Test):'
1083 return '+glob'
1084 return '+glob'
1084 return False
1085 return False
1085
1086
1087 def gettest(testdir, test, options, count):
1088 """Obtain a Test by looking at its filename.
1089
1090 Returns a Test instance. The Test may not be runnable if it doesn't map
1091 to a known type.
1092 """
1093
1094 lctest = test.lower()
1095 refpath = os.path.join(testdir, test)
1096
1097 runner = Test
1098
1099 for ext, cls, out in testtypes:
1100 if lctest.endswith(ext):
1101 runner = cls
1102 refpath = os.path.join(testdir, test + out)
1103 break
1104
1105 return runner(testdir, test, options, count, refpath)
1106
1086 wifexited = getattr(os, "WIFEXITED", lambda x: False)
1107 wifexited = getattr(os, "WIFEXITED", lambda x: False)
1087 def run(cmd, wd, options, replacements, env):
1108 def run(cmd, wd, options, replacements, env):
1088 """Run command in a sub-process, capturing the output (stdout and stderr).
1109 """Run command in a sub-process, capturing the output (stdout and stderr).
@@ -1129,31 +1150,6 b' def run(cmd, wd, options, replacements, '
1129 output = re.sub(s, r, output)
1150 output = re.sub(s, r, output)
1130 return ret, output.splitlines(True)
1151 return ret, output.splitlines(True)
1131
1152
1132 def runone(options, test, count):
1133 '''returns a result element: (code, test, msg)'''
1134
1135 def skip(msg):
1136 if options.verbose:
1137 log("\nSkipping %s: %s" % (testpath, msg))
1138 return 's', test, msg
1139
1140 lctest = test.lower()
1141
1142 for ext, cls, out in testtypes:
1143 if lctest.endswith(ext):
1144 runner = cls
1145 ref = os.path.join(TESTDIR, test + out)
1146 break
1147 else:
1148 return skip("unknown test type")
1149
1150 t = runner(TESTDIR, test, options, count, ref)
1151 result = t.run()
1152
1153 t.cleanup()
1154
1155 return result
1156
1157 _hgpath = None
1153 _hgpath = None
1158
1154
1159 def _gethgpath():
1155 def _gethgpath():
@@ -1195,7 +1191,9 b' def scheduletests(options, tests):'
1195
1191
1196 def job(test, count):
1192 def job(test, count):
1197 try:
1193 try:
1198 done.put(runone(options, test, count))
1194 t = gettest(TESTDIR, test, options, count)
1195 done.put(t.run())
1196 t.cleanup()
1199 except KeyboardInterrupt:
1197 except KeyboardInterrupt:
1200 pass
1198 pass
1201 except: # re-raises
1199 except: # re-raises
General Comments 0
You need to be logged in to leave comments. Login now