Skip to content

Commit

Permalink
rewrite some steps to not use removed IStatusLog methods
Browse files Browse the repository at this point in the history
This is in preparation for getText, readlines, etc. to be removed in
nine.  There are lots more steps to rewrite -- this is just a start.
  • Loading branch information
djmitche committed Nov 26, 2013
1 parent eeb29b1 commit a2bfdda
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
17 changes: 15 additions & 2 deletions master/buildbot/steps/maxq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@
# Copyright Buildbot Team Members

from buildbot import config
from buildbot.process import buildstep
from buildbot.status.results import FAILURE
from buildbot.status.results import SUCCESS
from buildbot.steps.shell import ShellCommand


class MaxQObserver(buildstep.LogLineObserver):

def __init__(self):
buildstep.LogLineObserver.__init__(self)
self.failures = 0

def outLineReceived(self, line):
if line.startswith('TEST FAILURE:'):
self.failures += 1


class MaxQ(ShellCommand):
flunkOnFailure = True
name = "maxq"
Expand All @@ -28,10 +40,11 @@ def __init__(self, testdir=None, **kwargs):
config.error("please pass testdir")
kwargs['command'] = 'run_maxq.py %s' % (testdir,)
ShellCommand.__init__(self, **kwargs)
self.observer = MaxQObserver()
self.addLogObserver('stdio', self.observer)

def commandComplete(self, cmd):
output = cmd.logs['stdio'].getText()
self.failures = output.count('\nTEST FAILURE:')
self.failures = self.observer.failures

def evaluateCommand(self, cmd):
# treat a nonzero exit status as a failure, if no other failures are
Expand Down
12 changes: 12 additions & 0 deletions master/buildbot/steps/package/deb/lintian.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@
"""

from buildbot import config
from buildbot.process import buildstep
from buildbot.status.results import FAILURE
from buildbot.status.results import SUCCESS
from buildbot.status.results import WARNINGS
from buildbot.steps.shell import ShellCommand


class MaxQObserver(buildstep.LogLineObserver):

def __init__(self):
buildstep.LogLineObserver.__init__(self)
self.failures = 0

def outLineReceived(self, line):
if line.startswith('TEST FAILURE:'):
self.failures += 1


class DebLintian(ShellCommand):
name = "lintian"
description = ["Lintian running"]
Expand Down
4 changes: 4 additions & 0 deletions master/buildbot/test/util/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def addLogObserver(logname, observer):
observer.step = step
step.addLogObserver = addLogObserver

# add any observers defined in the constructor, before this monkey-patch
for n, o in step._pendingLogObservers:
addLogObserver(n, o)

# set defaults

step.setDefaultWorkdir('wkdir')
Expand Down

0 comments on commit a2bfdda

Please sign in to comment.