Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Commit

Permalink
CDSK-953 - resolve Interpolate in ShellCommand._describe
Browse files Browse the repository at this point in the history
  • Loading branch information
warcholprzemo committed May 11, 2018
1 parent 160443d commit 1a074d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/steps/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def _describe(self, done=False):
return ["???"]

words = self.command
if isinstance(words, Interpolate):
words = words.getRenderingFor(self.build).result
if isinstance(words, (str, unicode)):
words = words.split()
elif isinstance(words, Interpolate):
return [str(words)]

try:
len(words)
Expand Down
13 changes: 11 additions & 2 deletions master/buildbot/test/unit/test_steps_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from buildbot.status.results import EXCEPTION
from buildbot.test.util import steps, compat
from buildbot.test.util import config as configmixin
from buildbot.test.fake.fakebuild import FakeBuild
from buildbot.test.fake.remotecommand import ExpectShell, Expect
from buildbot.test.fake.remotecommand import ExpectRemoteRef
from buildbot import config
Expand Down Expand Up @@ -73,9 +74,17 @@ def test_constructor_args_validity(self):
wrongArg1=1, wrongArg2='two'))

def test_describe_with_command_Interpolate(self):
command = Interpolate("echo 'test %s'", 'one fish')
bash_command = "sleep %d"
bash_command_arg = 60
expected_output = ["'sleep", "60'"]
build = FakeBuild()

command = Interpolate(bash_command, bash_command_arg)
step = shell.ShellCommand(command=command)
self.assertEqual(step.describe(), [str(command)])
step.build = build
output = step.describe()

self.assertEqual(expected_output, output)

def test_describe_no_command(self):
step = shell.ShellCommand(workdir='build')
Expand Down

0 comments on commit 1a074d6

Please sign in to comment.