tests/run-tests.py
changeset 24982 5c15f7e0f52b
parent 24981 012b79d549d8
child 24983 277bc9b0b4bd
equal deleted inserted replaced
24981:012b79d549d8 24982:5c15f7e0f52b
  1492             self.stream.writeln('Errored %s: %s' % (test.name, msg))
  1492             self.stream.writeln('Errored %s: %s' % (test.name, msg))
  1493 
  1493 
  1494         if self._runner.options.xunit:
  1494         if self._runner.options.xunit:
  1495             xuf = open(self._runner.options.xunit, 'wb')
  1495             xuf = open(self._runner.options.xunit, 'wb')
  1496             try:
  1496             try:
  1497                 timesd = dict(
  1497                 timesd = dict((t[0], t[3]) for t in result.times)
  1498                     (test, real) for test, cuser, csys, real in result.times)
       
  1499                 doc = minidom.Document()
  1498                 doc = minidom.Document()
  1500                 s = doc.createElement('testsuite')
  1499                 s = doc.createElement('testsuite')
  1501                 s.setAttribute('name', 'run-tests')
  1500                 s.setAttribute('name', 'run-tests')
  1502                 s.setAttribute('tests', str(result.testsRun))
  1501                 s.setAttribute('tests', str(result.testsRun))
  1503                 s.setAttribute('errors', "0") # TODO
  1502                 s.setAttribute('errors', "0") # TODO
  1529                 raise ImportError("json module not installed")
  1528                 raise ImportError("json module not installed")
  1530             jsonpath = os.path.join(self._runner._testdir, 'report.json')
  1529             jsonpath = os.path.join(self._runner._testdir, 'report.json')
  1531             fp = open(jsonpath, 'w')
  1530             fp = open(jsonpath, 'w')
  1532             try:
  1531             try:
  1533                 timesd = {}
  1532                 timesd = {}
  1534                 for test, cuser, csys, real in result.times:
  1533                 for tdata in result.times:
       
  1534                     test = tdata[0]
       
  1535                     real, cuser, csys = tdata[3], tdata[1], tdata[2]
  1535                     timesd[test] = (real, cuser, csys)
  1536                     timesd[test] = (real, cuser, csys)
  1536 
  1537 
  1537                 outcome = {}
  1538                 outcome = {}
  1538                 groups = [('success', ((tc, None) for tc in result.successes)),
  1539                 groups = [('success', ((tc, None) for tc in result.successes)),
  1539                           ('failure', result.failures),
  1540                           ('failure', result.failures),
  1571         self.stream.writeln('# Producing time report')
  1572         self.stream.writeln('# Producing time report')
  1572         times.sort(key=lambda t: (t[3]))
  1573         times.sort(key=lambda t: (t[3]))
  1573         cols = '%7.3f %7.3f %7.3f   %s'
  1574         cols = '%7.3f %7.3f %7.3f   %s'
  1574         self.stream.writeln('%-7s %-7s %-7s   %s' % ('cuser', 'csys', 'real',
  1575         self.stream.writeln('%-7s %-7s %-7s   %s' % ('cuser', 'csys', 'real',
  1575                     'Test'))
  1576                     'Test'))
  1576         for test, cuser, csys, real in times:
  1577         for tdata in times:
       
  1578             test = tdata[0]
       
  1579             cuser, csys, real = tdata[1:4]
  1577             self.stream.writeln(cols % (cuser, csys, real, test))
  1580             self.stream.writeln(cols % (cuser, csys, real, test))
  1578 
  1581 
  1579 class TestRunner(object):
  1582 class TestRunner(object):
  1580     """Holds context for executing tests.
  1583     """Holds context for executing tests.
  1581 
  1584