forked from buildbot/buildbot
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
properly report how many tests are executed if success, otherwise how many error/fail tests
- Loading branch information
tp
committed
Jun 17, 2010
1 parent
74d8970
commit 9a81f0d
Showing
2 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,79 @@ | ||
|
||
from buildbot.steps.shell import ShellCommand | ||
from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS, SKIPPED | ||
|
||
class SubunitShellCommand(ShellCommand): | ||
"""A ShellCommand that sniffs subunit output. | ||
Ideally not needed, and thus here to be trivially deleted. See issue #615 | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
ShellCommand.__init__(self, *args, **kwargs) | ||
# importing here gets around an import loop | ||
from buildbot.process import subunitlogobserver | ||
self.addLogObserver('stdio', subunitlogobserver.SubunitLogObserver()) | ||
self.ioObverser = subunitlogobserver.SubunitLogObserver() | ||
self.addLogObserver('stdio', self.ioObverser) | ||
self.progressMetrics = self.progressMetrics + ('tests', 'tests failed') | ||
def commandComplete(self, cmd): | ||
# figure out all statistics about the run | ||
ob = self.ioObverser | ||
failures = len(ob.failures) | ||
errors = len(ob.errors) | ||
skips = len(ob.skips) | ||
total = ob.testsRun | ||
|
||
count = failures + errors | ||
|
||
text = [] | ||
text2 = "" | ||
|
||
if not count: | ||
results = SUCCESS | ||
if total: | ||
text += ["%d %s" % \ | ||
(total, | ||
total == 1 and "test" or "tests"), | ||
"passed"] | ||
else: | ||
text += ["no tests", "run"] | ||
else: | ||
results = FAILURE | ||
text.append("tests") | ||
if failures: | ||
text.append("%d %s" % \ | ||
(failures, | ||
failures == 1 and "failure" or "failures")) | ||
if errors: | ||
text.append("%d %s" % \ | ||
(errors, | ||
errors == 1 and "error" or "errors")) | ||
text2 = "%d tes%s" % (count, (count == 1 and 't' or 'ts')) | ||
|
||
|
||
if skips: | ||
text.append("%d %s" % (skips, | ||
skips == 1 and "skip" or "skips")) | ||
|
||
#TODO: expectedFailures/unexpectedSuccesses | ||
|
||
self.results = results | ||
self.text = text | ||
self.text2 = [text2] | ||
|
||
def evaluateCommand(self, cmd): | ||
return self.results | ||
|
||
def createSummary(self, loog): | ||
ob = self.ioObverser | ||
problems = "" | ||
for test, err in ob.errors + ob.failures: | ||
problems += "%s\n%s" % (test, err) | ||
if problems: | ||
self.addCompleteLog("problems", problems) | ||
warnings = ob.warningio.getvalue() | ||
if warnings: | ||
self.addCompleteLog("warnings", warnings) | ||
|
||
def getText(self, cmd, results): | ||
return self.text | ||
def getText2(self, cmd, results): | ||
return self.text2 |