tests/run-tests.py
changeset 21340 fda36de1cb0e
parent 21339 de25e968b4d8
child 21341 cb88d4a04f58
equal deleted inserted replaced
21339:de25e968b4d8 21340:fda36de1cb0e
  1180 results = {'.':[], '!':[], '~': [], 's':[], 'i':[]}
  1180 results = {'.':[], '!':[], '~': [], 's':[], 'i':[]}
  1181 times = []
  1181 times = []
  1182 iolock = threading.Lock()
  1182 iolock = threading.Lock()
  1183 abort = False
  1183 abort = False
  1184 
  1184 
  1185 def scheduletests(options, tests):
  1185 def scheduletests(runner, options, tests):
  1186     jobs = options.jobs
  1186     jobs = options.jobs
  1187     done = queue.Queue()
  1187     done = queue.Queue()
  1188     running = 0
  1188     running = 0
  1189     count = 0
  1189     count = 0
  1190     global abort
  1190     global abort
  1220                 running += 1
  1220                 running += 1
  1221                 count += 1
  1221                 count += 1
  1222     except KeyboardInterrupt:
  1222     except KeyboardInterrupt:
  1223         abort = True
  1223         abort = True
  1224 
  1224 
  1225 def runtests(options, tests):
  1225 def runtests(runner, options, tests):
  1226     try:
  1226     try:
  1227         if INST:
  1227         if INST:
  1228             installhg(options)
  1228             installhg(options)
  1229             _checkhglib("Testing")
  1229             _checkhglib("Testing")
  1230         else:
  1230         else:
  1238                 tests.pop(0)
  1238                 tests.pop(0)
  1239             if not tests:
  1239             if not tests:
  1240                 print "running all tests"
  1240                 print "running all tests"
  1241                 tests = orig
  1241                 tests = orig
  1242 
  1242 
  1243         scheduletests(options, tests)
  1243         scheduletests(runner, options, tests)
  1244 
  1244 
  1245         failed = len(results['!'])
  1245         failed = len(results['!'])
  1246         warned = len(results['~'])
  1246         warned = len(results['~'])
  1247         tested = len(results['.']) + failed + warned
  1247         tested = len(results['.']) + failed + warned
  1248         skipped = len(results['s'])
  1248         skipped = len(results['s'])
  1276         return 80
  1276         return 80
  1277 
  1277 
  1278 testtypes = [('.py', PythonTest, '.out'),
  1278 testtypes = [('.py', PythonTest, '.out'),
  1279              ('.t', TTest, '')]
  1279              ('.t', TTest, '')]
  1280 
  1280 
       
  1281 class TestRunner(object):
       
  1282     """Holds context for executing tests.
       
  1283 
       
  1284     Tests rely on a lot of state. This object holds it for them.
       
  1285     """
       
  1286 
  1281 def main(args, parser=None):
  1287 def main(args, parser=None):
       
  1288     runner = TestRunner()
       
  1289 
  1282     parser = parser or getparser()
  1290     parser = parser or getparser()
  1283     (options, args) = parseargs(args, parser)
  1291     (options, args) = parseargs(args, parser)
  1284     os.umask(022)
  1292     os.umask(022)
  1285 
  1293 
  1286     checktools()
  1294     checktools()
  1395     vlog("# Using HGTMP", HGTMP)
  1403     vlog("# Using HGTMP", HGTMP)
  1396     vlog("# Using PATH", os.environ["PATH"])
  1404     vlog("# Using PATH", os.environ["PATH"])
  1397     vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
  1405     vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
  1398 
  1406 
  1399     try:
  1407     try:
  1400         return runtests(options, tests) or 0
  1408         return runtests(runner, options, tests) or 0
  1401     finally:
  1409     finally:
  1402         time.sleep(.1)
  1410         time.sleep(.1)
  1403         cleanup(options)
  1411         cleanup(options)
  1404 
  1412 
  1405 if __name__ == '__main__':
  1413 if __name__ == '__main__':