-
Notifications
You must be signed in to change notification settings - Fork 31
CDSK-953 - fix Interpolate has no length exception #364
Conversation
master/buildbot/steps/shell.py
Outdated
@@ -200,6 +201,8 @@ def _describe(self, done=False): | |||
words = self.command | |||
if isinstance(words, (str, unicode)): | |||
words = words.split() | |||
elif isinstance(words, Interpolate): | |||
return str(words) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure it is safe to return a string here?
The rest of code is always returning lists of strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I did not notice a type for return value.
b316d30
to
160443d
Compare
master/buildbot/steps/shell.py
Outdated
@@ -200,6 +201,8 @@ def _describe(self, done=False): | |||
words = self.command | |||
if isinstance(words, (str, unicode)): | |||
words = words.split() | |||
elif isinstance(words, Interpolate): | |||
return [str(words)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not sure this solution. Now we can not display just a part of interpolation and in a description, there will be always full version and as I can see, sometimes there is a very long shell command. I think we should consider how to split Interpolate
command.
@campos-ddc is it ok right now or we should change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking with Kamil I've changed str(Interpolate)
to resolve Interpolate with .getRenderingFor(self.build).result
@@ -71,6 +72,11 @@ def test_constructor_args_validity(self): | |||
lambda: shell.ShellCommand('build', "echo Hello World", | |||
wrongArg1=1, wrongArg2='two')) | |||
|
|||
def test_describe_with_command_Interpolate(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, you are also testing how casting work in Interpolate class. I think you should separate command to a string variable, and pass it as an argument to Interpolate
class and also assert that self.describe()
return this string in array form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. We check expected_output
with an output from step.describe()
Interpolate is not Iterable so we can resolve Interpolate to string and continue do a stuff in ShellCommand._describe