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  from StringIO import StringIO 
 6   
7 -class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
8 """Observe a log that may contain subunit output. 9 10 This class extends TestResult to receive the callbacks from the subunit 11 parser in the most direct fashion. 12 """ 13
14 - def __init__(self):
15 buildstep.LogLineObserver.__init__(self) 16 TestResult.__init__(self) 17 try: 18 from subunit import TestProtocolServer 19 except ImportError: 20 raise ImportError("subunit is not importable, but is required for " 21 "SubunitLogObserver support.") 22 self.warningio = StringIO() 23 self.protocol = TestProtocolServer(self, self.warningio) 24 self.skips = [] 25 self.seen_tags = set() #don't yet know what tags does in subunit
26
27 - def outLineReceived(self, line):
28 """Process a received stdout line.""" 29 # Impedance mismatch: subunit wants lines, observers get lines-no\n 30 self.protocol.lineReceived(line + '\n')
31
32 - def errLineReceived(self, line):
33 """same for stderr line.""" 34 self.protocol.lineReceived(line + '\n')
35
36 - def startTest(self, test):
37 TestResult.startTest(self, test) 38 self.step.setProgress('tests', self.testsRun)
39
40 - def addSkip(self, test, detail):
41 if hasattr(TestResult,'addSkip'): 42 TestResult.addSkip(self, test, detail) 43 else: 44 self.skips.append((test, detail))
45
46 - def addError(self, test, err):
47 TestResult.addError(self, test, err) 48 self.issue()
49
50 - def addFailure(self, test, err):
51 TestResult.addFailure(self, test, err) 52 self.issue()
53
54 - def issue(self):
55 """An issue - failing, erroring etc test.""" 56 self.step.setProgress('tests failed', len(self.failures) + 57 len(self.errors))
58
59 - def tags(self, new_tags, gone_tags):
60 """Accumulate the seen tags.""" 61 self.seen_tags.update(new_tags)
62 63 # this used to be referenced here, so we keep a link for old time's sake 64 import buildbot.steps.subunit 65 SubunitShellCommand = buildbot.steps.subunit.SubunitShellCommand 66