Skip to content

Commit

Permalink
Expose mechanism for steps to override the version of the shell command
Browse files Browse the repository at this point in the history
This is useful to avoid having to control the version of commands being
tested in unit tests
  • Loading branch information
Vitali Lovich committed Jul 28, 2015
1 parent f3c5cad commit a9bb07e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions master/buildbot/test/util/steps.py
Expand Up @@ -64,6 +64,16 @@ def tearDownBuildStep(self):
del remotecommand.FakeRemoteCommand.testcase

# utilities
def _getSlaveCommandVersionWrapper(self):
originalGetSlaveCommandVersion = self.step.build.getSlaveCommandVersion

def getSlaveCommandVersion(cmd, oldversion):
if cmd == 'shell':
if hasattr(self, 'slaveShellCommandVersion'):
return self.slaveShellCommandVersion
return originalGetSlaveCommandVersion(cmd, oldversion)

return getSlaveCommandVersion

def setupStep(self, step, slave_version={'*': "99.99"}, slave_env={},
buildFiles=[], wantDefaultWorkdir=True):
Expand Down Expand Up @@ -216,6 +226,8 @@ def runStep(self):
@returns: Deferred
"""
self.step.build.getSlaveCommandVersion = self._getSlaveCommandVersionWrapper()

self.conn = mock.Mock(name="SlaveBuilder(connection)")
self.step.setupProgress()
d = self.step.startStep(self.conn)
Expand Down

0 comments on commit a9bb07e

Please sign in to comment.