Package buildbot :: Package process :: Module subunitlogobserver
[frames] | no frames]

Source Code for Module buildbot.process.subunitlogobserver

 1  # -*- test-case-name: buildbot.test.test_buildstep -*- 
 2   
 3  from unittest import TestResult 
 4  from buildbot.process import buildstep 
 5   
6 -class DiscardStream:
7 """A trivial thunk used to discard passthrough content.""" 8
9 - def write(self, bytes):
10 pass
11 12
13 -class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
14 """Observe a log that may contain subunit output. 15 16 This class extends TestResult to receive the callbacks from the subunit 17 parser in the most direct fashion. 18 """ 19
20 - def __init__(self):
21 buildstep.LogLineObserver.__init__(self) 22 TestResult.__init__(self) 23 try: 24 from subunit import TestProtocolServer 25 except ImportError: 26 raise ImportError("subunit is not importable, but is required for " 27 "SubunitLogObserver support.") 28 self.protocol = TestProtocolServer(self, DiscardStream())
29
30 - def outLineReceived(self, line):
31 """Process a received line.""" 32 # Impedance mismatch: subunit wants lines, observers get lines-no\n 33 self.protocol.lineReceived(line + '\n')
34
35 - def startTest(self, test):
36 TestResult.startTest(self, test) 37 self.step.setProgress('tests', self.testsRun)
38
39 - def addError(self, test, err):
40 TestResult.addError(self, test, err) 41 self.issue()
42
43 - def addFailure(self, test, err):
44 TestResult.addFailure(self, test, err) 45 self.issue()
46
47 - def issue(self):
48 """An issue - failing, erroring etc test.""" 49 self.step.setProgress('tests failed', len(self.failures) + len(self.errors))
50 51 # this used to be referenced here, so we keep a link for old time's sake 52 import buildbot.steps.subunit 53 SubunitShellCommand = buildbot.steps.subunit.SubunitShellCommand 54