3
import twisted.python.log
5
1
import buildbot.process.buildstep
6
2
import buildbot.steps.shell
9
class TestObserver(buildbot.process.buildstep.LogLineObserver):
10
# adds a summary log, and keeps track of test count as we go.
12
_ignore_line = re.compile(
13
r'( [\w\.\/\-]+( ?\([\w\.\/\-]+\))?|'
15
r'\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}\:\d{2} INFO.+|'
18
r' Ran \d+ tests with .+)$').match
20
# Ran 223 tests with 0 failures and 0 errors in 3 minutes 0.483 seconds.
21
_intermediate_summary = re.compile(
22
r' Ran (\d+) tests? with (\d+) failures? and (\d+) errors? '
23
r'in .*?[\d\.]+ seconds?.').match
25
#Total: 20302 tests, 0 failures, 0 errors in 141 minutes 5.392 seconds.
26
_final_summary = re.compile(
27
r'Total: (\d+) tests?, (\d+) failures?, (\d+) errors? '
28
r'in .*?[\d\.]+ seconds?.').match
37
def outLineReceived(self, line):
41
self.log = self.step.addLog('summary')
43
match = self._intermediate_summary(line)
45
total, failures, errors = match.groups()
46
self.test_count += int(total)
47
self.failure_count += int(failures)
48
self.error_count += int(errors)
50
match = self._final_summary(line)
53
total, failures, errors = match.groups()
54
self.test_count = int(total)
55
self.failure_count = int(failures)
56
self.error_count = int(errors)
59
report = not self._ignore_line(line)
61
self.log.addStdout(line + '\n')
63
twisted.python.log.msg(
64
'%d tests, %d failures, %d errors' %
65
(self.test_count, self.failure_count, self.error_count))
66
self.step.setProgress('tests', self.test_count)
67
self.step.step_status.setStatistic(
68
'tests-total', self.test_count)
69
self.step.step_status.setStatistic(
70
'tests-failures', self.failure_count)
71
self.step.step_status.setStatistic(
72
'tests-errors', self.error_count)
73
self.step.step_status.setText(self.step.describe(False))
4
from bzrbuildbot.subunittest import SubunitObserver
8
buildbot.process.buildstep.LogLineObserver, SubunitObserver):
78
12
class Test(buildbot.steps.shell.ShellCommand):