Skip to content

Commit

Permalink
Update status string handling for most tests
Browse files Browse the repository at this point in the history
There are still some failing tests due to a lingering issue around
BuildStep no longer supporting a `describe` method.
  • Loading branch information
djmitche committed Sep 25, 2014
1 parent 10db550 commit e256497
Show file tree
Hide file tree
Showing 48 changed files with 762 additions and 772 deletions.
92 changes: 27 additions & 65 deletions master/buildbot/process/buildstep.py
Expand Up @@ -47,6 +47,7 @@
from buildbot.status.results import EXCEPTION
from buildbot.status.results import FAILURE
from buildbot.status.results import RETRY
from buildbot.status.results import Results
from buildbot.status.results import SKIPPED
from buildbot.status.results import SUCCESS
from buildbot.status.results import WARNINGS
Expand Down Expand Up @@ -313,20 +314,6 @@ def __new__(klass, *args, **kwargs):
self._factory = _BuildStepFactory(klass, *args, **kwargs)
return self

def _describe(self, done=False):
if self.descriptionDone and done:
return self.descriptionDone
elif self.description:
return self.description
return [self.name]

def describe(self, done=False):
assert(self.rendered)
desc = self._describe(done)
if self.descriptionSuffix:
desc = desc + self.descriptionSuffix
return desc

def setBuild(self, build):
self.build = build
self.master = self.build.master
Expand Down Expand Up @@ -358,10 +345,28 @@ def setProgress(self, metric, value):
self.progress.setProgress(metric, value)

def getCurrentSummary(self):
return {u'step': u'running'}
if self.description is not None:
stepsumm = util.join_list(self.description)
if self.descriptionSuffix:
stepsumm += u' ' + util.join_list(self.descriptionSuffix)
else:
stepsumm = u'running'
return {u'step': stepsumm}

def getResultSummary(self):
return {}
if self.descriptionDone is not None or self.description is not None:
stepsumm = util.join_list(self.descriptionDone or self.description)
if self.descriptionSuffix:
stepsumm += u' ' + util.join_list(self.descriptionSuffix)
else:
stepsumm = u'finished'

if self.results != SUCCESS:
stepsumm += u' (%s)' % Results[self.results]

return {u'step': stepsumm}

# TODO: test those^^

@debounce.method(wait=1)
@defer.inlineCallbacks
Expand All @@ -381,14 +386,14 @@ def methodInfo(m):

stepResult = summary.get('step', u'finished')
if not isinstance(stepResult, unicode):
raise TypeError("step result must be unicode")
raise TypeError("step result string must be unicode")
yield self.master.data.updates.setStepStateStrings(self.stepid,
[stepResult])

if not self._running:
buildResult = summary.get('build', None)
if buildResult and not isinstance(buildResult, unicode):
raise TypeError("build result must be unicode")
raise TypeError("build result string must be unicode")
# updateSummary gets patched out for old-style steps, so keep a copy we can
# call internally for such steps
realUpdateSummary = updateSummary
Expand Down Expand Up @@ -491,6 +496,7 @@ def setRenderable(res, attr):

# update the summary one last time, make sure that completes,
# and then don't update it any more.
self.results = results
self.realUpdateSummary()
yield self.realUpdateSummary.stop()

Expand Down Expand Up @@ -886,6 +892,7 @@ def evaluateCommand(self, cmd):
return self.log_eval_func(cmd, self.step_status)
return cmd.results()

# TODO: delete
def getText(self, cmd, results):
if results == SUCCESS:
return self.describe(True)
Expand All @@ -898,9 +905,11 @@ def getText(self, cmd, results):
else:
return self.describe(True) + ["failed"]

# TODO: delete
def getText2(self, cmd, results):
return [self.name]

# TODO: delete
def maybeGetText2(self, cmd, results):
if results == SUCCESS:
# successful steps do not add anything to the build's text
Expand Down Expand Up @@ -1078,53 +1087,6 @@ def makeRemoteShellCommand(self, collectStdout=False, collectStderr=False,

defer.returnValue(cmd)

def _describe(self, done=False):
try:
if done and self.descriptionDone is not None:
return self.descriptionDone
if self.description is not None:
return self.description

# if self.cmd is set, then use the RemoteCommand's info
if self.cmd:
command = self.command.command
# otherwise, if we were configured with a command, use that
elif self.command:
command = self.command
else:
return super(ShellMixin, self)._describe(done)

words = command
if isinstance(words, (str, unicode)):
words = words.split()

try:
len(words)
except (AttributeError, TypeError):
# WithProperties and Property don't have __len__
# For old-style classes instances AttributeError raised,
# for new-style classes instances - TypeError.
return super(ShellMixin, self)._describe(done)

# flatten any nested lists
words = flatten(words, (list, tuple))

# strip instances and other detritus (which can happen if a
# description is requested before rendering)
words = [w for w in words if isinstance(w, (str, unicode))]

if len(words) < 1:
return super(ShellMixin, self)._describe(done)
if len(words) == 1:
return ["'%s'" % words[0]]
if len(words) == 2:
return ["'%s" % words[0], "%s'" % words[1]]
return ["'%s" % words[0], "%s" % words[1], "...'"]

except Exception:
log.err(failure.Failure(), "Error describing step")
return super(ShellMixin, self)._describe(done)

# Parses the logs for a list of regexs. Meant to be invoked like:
# regexes = ((re.compile(...), FAILURE), (re.compile(...), WARNINGS))
# self.addStep(ShellCommand,
Expand Down
11 changes: 3 additions & 8 deletions master/buildbot/steps/http.py
Expand Up @@ -87,7 +87,8 @@ def __init__(self, url, method, description=None, descriptionDone=None, **kwargs
BuildStep.__init__(self, **kwargs)

def start(self):
self.doRequest()
d = self.doRequest()
d.addErrback(self.failed)

@defer.inlineCallbacks
def doRequest(self):
Expand Down Expand Up @@ -134,8 +135,7 @@ def doRequest(self):

log.finish()

self.descriptionDone = "Status code: %d" % r.status_code
self.step_status.setText(self.describe(done=True))
self.descriptionDone = ["Status code: %d" % r.status_code]
if (r.status_code < 400):
self.finished(SUCCESS)
else:
Expand All @@ -162,11 +162,6 @@ def log_response(self, response):
log.addStdout(' ------ Content ------\n%s' % response.text)
self.addLog('content').addStdout(response.text)

def describe(self, done=False):
if done:
return self.descriptionDone.split()
return self.description.split()


class POST(HTTPStep):

Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/steps/maxq.py
Expand Up @@ -55,7 +55,7 @@ def evaluateCommand(self, cmd):
return FAILURE
return SUCCESS

def getText(self, cmd, results):
def getResultSummary(self):
if self.failures:
return [str(self.failures), 'maxq', 'failures']
return ['maxq', 'tests']
return {u'step': u"%d maxq failures" % self.failures}
return {u'step': u'success'}
8 changes: 2 additions & 6 deletions master/buildbot/steps/package/deb/pbuilder.py
Expand Up @@ -37,8 +37,8 @@ class DebPbuilder(WarningCountingShellCommand):

haltOnFailure = 1
flunkOnFailure = 1
description = ["pdebuilding"]
descriptionDone = ["pdebuild"]
description = ["building"]
descriptionDone = ["built"]

warningPattern = r".*(warning[: ]|\sW: ).*"

Expand Down Expand Up @@ -171,7 +171,6 @@ def checkBasetgz(self, cmd):
stdio_log = stdio_log = self.addLog("pbuilder")
cmd.useLog(stdio_log, True, "stdio")
d = self.runCommand(cmd)
self.step_status.setText(["PBuilder update."])
d.addCallback(lambda res: self.startBuild(cmd))
return d
return self.startBuild(cmd)
Expand Down Expand Up @@ -200,9 +199,6 @@ class DebCowbuilder(DebPbuilder):
"""Build a debian package with cowbuilder inside of a chroot."""
name = "cowbuilder"

description = ["pdebuilding"]
descriptionDone = ["pdebuild"]

basetgz = "/var/cache/pbuilder/%(distribution)s-%(architecture)s-buildbot.cow/"

pbuilder = '/usr/sbin/cowbuilder'
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/steps/python_twisted.py
Expand Up @@ -595,6 +595,7 @@ def createSummary(self, loog):
def evaluateCommand(self, cmd):
return self.results

# TODO: better rewrite this as new-style
def getText(self, cmd, results):
return self.text

Expand Down

0 comments on commit e256497

Please sign in to comment.