1188 resultslock = threading.Lock() |
1188 resultslock = threading.Lock() |
1189 times = [] |
1189 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 |
1199 |
1200 if options.first and code not in '.si': |
1200 def job(test, count): |
1201 break |
1201 try: |
|
1202 done.put(runone(options, test, count)) |
|
1203 except KeyboardInterrupt: |
|
1204 pass |
|
1205 |
|
1206 try: |
|
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: |
1205 if INST: |
1228 if INST: |
1206 installhg(options) |
1229 installhg(options) |
1216 tests.pop(0) |
1239 tests.pop(0) |
1217 if not tests: |
1240 if not 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 |
1225 skipped = len(results['s']) |
1248 skipped = len(results['s']) |
1226 ignored = len(results['i']) |
1249 ignored = len(results['i']) |
1347 vlog("# Using HGTMP", HGTMP) |
1370 vlog("# Using HGTMP", HGTMP) |
1348 vlog("# Using PATH", os.environ["PATH"]) |
1371 vlog("# Using PATH", os.environ["PATH"]) |
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) |
1359 |
1379 |
1360 if __name__ == '__main__': |
1380 if __name__ == '__main__': |