Package buildbot :: Package steps :: Module subunit
[frames] | no frames]

Source Code for Module buildbot.steps.subunit

 1   
 2  from buildbot.steps.shell import ShellCommand 
 3  from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS, SKIPPED 
 4   
5 -class SubunitShellCommand(ShellCommand):
6 """A ShellCommand that sniffs subunit output. 7 """ 8
9 - def __init__(self, *args, **kwargs):
10 ShellCommand.__init__(self, *args, **kwargs) 11 # importing here gets around an import loop 12 from buildbot.process import subunitlogobserver 13 self.ioObverser = subunitlogobserver.SubunitLogObserver() 14 self.addLogObserver('stdio', self.ioObverser) 15 self.progressMetrics = self.progressMetrics + ('tests', 'tests failed')
16 - def commandComplete(self, cmd):
17 # figure out all statistics about the run 18 ob = self.ioObverser 19 failures = len(ob.failures) 20 errors = len(ob.errors) 21 skips = len(ob.skips) 22 total = ob.testsRun 23 24 count = failures + errors 25 26 text = [self.name] 27 text2 = "" 28 29 if not count: 30 results = SUCCESS 31 if total: 32 text += ["%d %s" % \ 33 (total, 34 total == 1 and "test" or "tests"), 35 "passed"] 36 else: 37 text += ["no tests", "run"] 38 else: 39 results = FAILURE 40 if failures: 41 text.append("%d %s" % \ 42 (failures, 43 failures == 1 and "failure" or "failures")) 44 if errors: 45 text.append("%d %s" % \ 46 (errors, 47 errors == 1 and "error" or "errors")) 48 text2 = "%d tes%s" % (count, (count == 1 and 't' or 'ts')) 49 50 51 if skips: 52 text.append("%d %s" % (skips, 53 skips == 1 and "skip" or "skips")) 54 55 #TODO: expectedFailures/unexpectedSuccesses 56 57 self.results = results 58 self.text = text 59 self.text2 = [text2]
60
61 - def evaluateCommand(self, cmd):
62 return self.results
63
64 - def createSummary(self, loog):
65 ob = self.ioObverser 66 problems = "" 67 for test, err in ob.errors + ob.failures: 68 problems += "%s\n%s" % (test.id(), err) 69 if problems: 70 self.addCompleteLog("problems", problems) 71 warnings = ob.warningio.getvalue() 72 if warnings: 73 self.addCompleteLog("warnings", warnings)
74
75 - def getText(self, cmd, results):
76 return self.text
77 - def getText2(self, cmd, results):
78 return self.text2
79