class RubyTest(shell.Test): """Parse the summary line from the Test::Unit Console runner. Our script does not modify its error code when tests fail, so we parse the last line of the output to get the numbers. """ summary_re = re.compile('^(?P<tests>\d+) tests, ' '(?P<assertions>\d+) assertions, ' '(?P<failures>\d+) failures, ' '(?P<errors>\d+) errors') testunit_results = None def commandComplete(self, cmd): output = cmd.logs['stdio'].getText() summary_line = output.splitlines()[-1] match = self.summary_re.match(summary_line) if match: result_strings = match.groupdict() self.testunit_results = {} for k, v in result_strings.items(): self.testunit_results[k] = int(v) else: from twisted.python import log log.msg("match failed: %s from %r" % (match, summary_line)) def evaluateCommand(self, cmd): if (cmd.rc != 0) or (not self.testunit_results): return shell.FAILURE if self.testunit_results['failures'] or self.testunit_results['errors']: return shell.FAILURE return shell.SUCCESS def getText2(self, cmd, results): if not self.testunit_results: return [self.name] r = [] for x in 'errors', 'failures': if self.testunit_results[x]: r.append('%d %s' % (self.testunit_results[x], x)) return r def describe(self, done=False): if not done: return ["testing"] if not self.testunit_results: return ["tests"] r = [] for x in 'errors', 'failures', 'tests', 'assertions': if self.testunit_results[x]: r.append('%d %s' % (self.testunit_results[x], x)) return r
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)