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

Source Code for Module buildbot.process.subunitlogobserver

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16   
17  from unittest import TestResult 
18  from buildbot.process import buildstep 
19  from StringIO import StringIO 
20   
21 -class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
22 """Observe a log that may contain subunit output. 23 24 This class extends TestResult to receive the callbacks from the subunit 25 parser in the most direct fashion. 26 """ 27
28 - def __init__(self):
29 buildstep.LogLineObserver.__init__(self) 30 TestResult.__init__(self) 31 try: 32 from subunit import TestProtocolServer 33 except ImportError: 34 raise ImportError("subunit is not importable, but is required for " 35 "SubunitLogObserver support.") 36 self.warningio = StringIO() 37 self.protocol = TestProtocolServer(self, self.warningio) 38 self.skips = [] 39 self.seen_tags = set() #don't yet know what tags does in subunit
40
41 - def outLineReceived(self, line):
42 """Process a received stdout line.""" 43 # Impedance mismatch: subunit wants lines, observers get lines-no\n 44 self.protocol.lineReceived(line + '\n')
45
46 - def errLineReceived(self, line):
47 """same for stderr line.""" 48 self.protocol.lineReceived(line + '\n')
49
50 - def startTest(self, test):
51 TestResult.startTest(self, test) 52 self.step.setProgress('tests', self.testsRun)
53
54 - def addSkip(self, test, detail):
55 if hasattr(TestResult,'addSkip'): 56 TestResult.addSkip(self, test, detail) 57 else: 58 self.skips.append((test, detail))
59
60 - def addError(self, test, err):
61 TestResult.addError(self, test, err) 62 self.issue()
63
64 - def addFailure(self, test, err):
65 TestResult.addFailure(self, test, err) 66 self.issue()
67
68 - def issue(self):
69 """An issue - failing, erroring etc test.""" 70 self.step.setProgress('tests failed', len(self.failures) + 71 len(self.errors))
72
73 - def tags(self, new_tags, gone_tags):
74 """Accumulate the seen tags.""" 75 self.seen_tags.update(new_tags)
76 77 # this used to be referenced here, so we keep a link for old time's sake 78 import buildbot.steps.subunit 79 SubunitShellCommand = buildbot.steps.subunit.SubunitShellCommand 80