Skip to content

Commit

Permalink
Move setText out of setStepStatus into startStep.
Browse files Browse the repository at this point in the history
When called in setStepStatus, properties for commands may not yet be
set, and so KeyError exceptions are raised.

setText must be called before stepStarted is called, so that status
receivers see the proper description.
  • Loading branch information
Chris AtLee committed Mar 4, 2010
1 parent c76b704 commit 3696fad
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 11 deletions.
1 change: 1 addition & 0 deletions buildbot/broken_test/runutils.py
Expand Up @@ -340,6 +340,7 @@ def makeBuildStep(basedir, step_class=BuildStep, **kwargs):
b.build_status = bss.getBuild()
b.setupProperties()
s.slaveVersion = fake_slaveVersion
s.step_status.setText(s.describe(False))
return s


Expand Down
10 changes: 7 additions & 3 deletions buildbot/process/buildstep.py
Expand Up @@ -619,6 +619,9 @@ def __init__(self, **kwargs):
raise TypeError(why)
self._pendingLogObservers = []

def describe(self, done=False):
return [self.name]

def setBuild(self, build):
# subclasses which wish to base their behavior upon qualities of the
# Build (e.g. use the list of changed files to run unit tests only on
Expand Down Expand Up @@ -733,6 +736,10 @@ def acquireLocks(self, res=None):
def _startStep_2(self, res):
if self.progress:
self.progress.start()

# Set the step's text here so that the stepStarted notification sees
# the correct description
self.step_status.setText(self.describe(False))
self.step_status.stepStarted()
try:
skip = None
Expand Down Expand Up @@ -992,9 +999,6 @@ def __init__(self, logfiles={}, lazylogfiles=False, *args, **kwargs):
self.lazylogfiles = lazylogfiles
self.addLogObserver('stdio', OutputProgressObserver("output"))

def describe(self, done=False):
raise NotImplementedError("implement this in a subclass")

def addLogFile(self, logname, filename):
"""
This allows to add logfiles after construction, but before calling
Expand Down
4 changes: 0 additions & 4 deletions buildbot/steps/shell.py
Expand Up @@ -105,10 +105,6 @@ def __init__(self, workdir=None,
def setStepStatus(self, step_status):
LoggingBuildStep.setStepStatus(self, step_status)

# start doesn't set text soon enough to capture our description in
# the stepStarted status notification. Set text here so it's included.
self.step_status.setText(self.describe(False))

def setDefaultWorkdir(self, workdir):
rkw = self.remote_kwargs
rkw['workdir'] = rkw['workdir'] or workdir
Expand Down
4 changes: 0 additions & 4 deletions buildbot/steps/source.py
Expand Up @@ -145,10 +145,6 @@ def __init__(self, workdir=None, mode='update', alwaysUseLatest=False,
def setStepStatus(self, step_status):
LoggingBuildStep.setStepStatus(self, step_status)

# start doesn't set text soon enough to capture our description in
# the stepStarted status notification. Set text here so it's included.
self.step_status.setText(self.describe(False))

def setDefaultWorkdir(self, workdir):
self.args['workdir'] = self.args['workdir'] or workdir

Expand Down
Empty file.
60 changes: 60 additions & 0 deletions buildbot/test/regressions/test_shell_command_properties.py
@@ -0,0 +1,60 @@
from twisted.trial import unittest

from buildbot.steps.shell import ShellCommand, SetProperty
from buildbot.process.properties import WithProperties, Properties
from buildbot.process.factory import BuildFactory
from buildbot.buildrequest import BuildRequest
from buildbot.sourcestamp import SourceStamp

class FakeSlaveBuilder:
slave = None

class FakeBuildStatus:
def __init__(self):
self.names = []

def addStepWithName(self, name):
self.names.append(name)
return FakeStepStatus()

def getProperties(self):
return Properties()

def setSourceStamp(self, ss):
self.ss = ss

def setReason(self, reason):
self.reason = reason

def setBlamelist(self, bl):
self.bl = bl

def setProgress(self, p):
self.progress = p


class FakeStepStatus:
txt = None
def setText(self, txt):
self.txt = txt

def setProgress(self, sp):
pass


class TestShellCommandProperties(unittest.TestCase):
def testCommand(self):
f = BuildFactory()
f.addStep(SetProperty(command=["echo", "value"], property="propname"))
f.addStep(ShellCommand(command=["echo", WithProperties("%(propname)s")]))

ss = SourceStamp()

req = BuildRequest("Testing", ss, None)

b = f.newBuild([req])
b.build_status = FakeBuildStatus()
b.slavebuilder = FakeSlaveBuilder()

# This shouldn't raise an exception
b.setupBuild(None)

0 comments on commit 3696fad

Please sign in to comment.