tests/run-tests.py
changeset 21358 fcc2e02e91a2
parent 21357 4c4f64b8df3c
child 21359 7982475da46a
equal deleted inserted replaced
21357:4c4f64b8df3c 21358:fcc2e02e91a2
   395 
   395 
   396     def __init__(self, runner, test, count, refpath):
   396     def __init__(self, runner, test, count, refpath):
   397         path = os.path.join(runner.testdir, test)
   397         path = os.path.join(runner.testdir, test)
   398         errpath = os.path.join(runner.testdir, '%s.err' % test)
   398         errpath = os.path.join(runner.testdir, '%s.err' % test)
   399 
   399 
       
   400         self._runner = runner
   400         self._testdir = runner.testdir
   401         self._testdir = runner.testdir
   401         self._test = test
   402         self._test = test
   402         self._path = path
   403         self._path = path
   403         self._options = runner.options
   404         self._options = runner.options
   404         self._count = count
   405         self._count = count
   544             iolock.acquire()
   545             iolock.acquire()
   545             sys.stdout.write(res[0])
   546             sys.stdout.write(res[0])
   546             sys.stdout.flush()
   547             sys.stdout.flush()
   547             iolock.release()
   548             iolock.release()
   548 
   549 
   549         times.append((self._test, duration))
   550         self._runner.times.append((self._test, duration))
   550 
   551 
   551         return res
   552         return res
   552 
   553 
   553     def _run(self, testtmp, replacements, env):
   554     def _run(self, testtmp, replacements, env):
   554         # This should be implemented in child classes to run tests.
   555         # This should be implemented in child classes to run tests.
   989     finally:
   990     finally:
   990         pipe.close()
   991         pipe.close()
   991     return _hgpath
   992     return _hgpath
   992 
   993 
   993 results = {'.':[], '!':[], '~': [], 's':[], 'i':[]}
   994 results = {'.':[], '!':[], '~': [], 's':[], 'i':[]}
   994 times = []
       
   995 iolock = threading.Lock()
   995 iolock = threading.Lock()
   996 abort = False
   996 abort = False
   997 
   997 
   998 def scheduletests(runner, tests):
   998 def scheduletests(runner, tests):
   999     jobs = runner.options.jobs
   999     jobs = runner.options.jobs
  1106         self.inst = None
  1106         self.inst = None
  1107         self.bindir = None
  1107         self.bindir = None
  1108         self.tmpbinddir = None
  1108         self.tmpbinddir = None
  1109         self.pythondir = None
  1109         self.pythondir = None
  1110         self.coveragefile = None
  1110         self.coveragefile = None
       
  1111         self.times = [] # Holds execution times of tests.
  1111         self._createdfiles = []
  1112         self._createdfiles = []
  1112 
  1113 
  1113     def gettest(self, test, count):
  1114     def gettest(self, test, count):
  1114         """Obtain a Test by looking at its filename.
  1115         """Obtain a Test by looking at its filename.
  1115 
  1116 
  1272                              '         (expected %s)\n'
  1273                              '         (expected %s)\n'
  1273                              % (verb, actualhg, expecthg))
  1274                              % (verb, actualhg, expecthg))
  1274 
  1275 
  1275     def outputtimes(self):
  1276     def outputtimes(self):
  1276         vlog('# Producing time report')
  1277         vlog('# Producing time report')
  1277         times.sort(key=lambda t: (t[1], t[0]), reverse=True)
  1278         self.times.sort(key=lambda t: (t[1], t[0]), reverse=True)
  1278         cols = '%7.3f   %s'
  1279         cols = '%7.3f   %s'
  1279         print '\n%-7s   %s' % ('Time', 'Test')
  1280         print '\n%-7s   %s' % ('Time', 'Test')
  1280         for test, timetaken in times:
  1281         for test, timetaken in self.times:
  1281             print cols % (timetaken, test)
  1282             print cols % (timetaken, test)
  1282 
  1283 
  1283     def outputcoverage(self):
  1284     def outputcoverage(self):
  1284         vlog('# Producing coverage report')
  1285         vlog('# Producing coverage report')
  1285         os.chdir(self.pythondir)
  1286         os.chdir(self.pythondir)