##// END OF EJS Templates
run-tests: introduce thread scheduler
Matt Mackall -
r19276:e5575196 default
parent child Browse files
Show More
@@ -1190,15 +1190,38 b' times = []'
1190 iolock = threading.Lock()
1190 iolock = threading.Lock()
1191 abort = False
1191 abort = False
1192
1192
1193 def runqueue(options, tests):
1193 def scheduletests(options, tests):
1194 for test in tests:
1194 jobs = options.jobs
1195 code, test, msg = runone(options, test, 0)
1195 done = queue.Queue()
1196 resultslock.acquire()
1196 running = 0
1197 results[code].append((test, msg))
1197 count = 0
1198 resultslock.release()
1198 global abort
1199
1200 def job(test, count):
1201 try:
1202 done.put(runone(options, test, count))
1203 except KeyboardInterrupt:
1204 pass
1199
1205
1200 if options.first and code not in '.si':
1206 try:
1201 break
1207 while tests or running:
1208 if not done.empty() or running == jobs or not tests:
1209 try:
1210 code, test, msg = done.get(True, 1)
1211 results[code].append((test, msg))
1212 if options.first and code not in '.si':
1213 break
1214 except queue.Empty:
1215 continue
1216 running -= 1
1217 if tests and not running == jobs:
1218 test = tests.pop(0)
1219 t = threading.Thread(None, job, args=(test, count))
1220 t.start()
1221 running += 1
1222 count += 1
1223 except KeyboardInterrupt:
1224 abort = True
1202
1225
1203 def runtests(options, tests):
1226 def runtests(options, tests):
1204 try:
1227 try:
@@ -1218,7 +1241,7 b' def runtests(options, tests):'
1218 print "running all tests"
1241 print "running all tests"
1219 tests = orig
1242 tests = orig
1220
1243
1221 runqueue(options, tests)
1244 scheduletests(options, tests)
1222
1245
1223 failed = len(results['!'])
1246 failed = len(results['!'])
1224 tested = len(results['.']) + failed
1247 tested = len(results['.']) + failed
@@ -1349,10 +1372,7 b' def main():'
1349 vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
1372 vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
1350
1373
1351 try:
1374 try:
1352 if len(tests) > 1 and options.jobs > 1:
1375 runtests(options, tests)
1353 runchildren(options, tests)
1354 else:
1355 runtests(options, tests)
1356 finally:
1376 finally:
1357 time.sleep(.1)
1377 time.sleep(.1)
1358 cleanup(options)
1378 cleanup(options)
General Comments 0
You need to be logged in to leave comments. Login now