[IMP] runbot: default empty value for result

This commit is contained in:
Xavier-Do 2023-01-13 12:04:35 +01:00 committed by Christophe Monniez
parent 6892546d94
commit 2b8242cf42
2 changed files with 2 additions and 2 deletions

View File

@ -930,7 +930,7 @@ class ConfigStep(models.Model):
def _make_python_results(self, build):
eval_ctx = self.make_python_ctx(build)
safe_eval(self.python_result_code.strip(), eval_ctx, mode="exec", nocopy=True)
return_value = eval_ctx.get('return_value')
return_value = eval_ctx.get('return_value', {})
# todo check return_value or write in try except. Example: local result setted to wrong value
if not isinstance(return_value, dict):
raise RunbotException('python_result_code must set return_value to a dict values on build')

View File

@ -674,7 +674,7 @@ Initiating shutdown
self.assertEqual(result, {'local_result': 'ok'})
# invalid result code (no return_value set)
config_step.python_result_code = """a = 2*5\nr = {'a': 'ok'}"""
config_step.python_result_code = """a = 2*5\nr = {'a': 'ok'}\nreturn_value = 'ko'"""
with self.assertRaises(RunbotException):
result = config_step._make_results(build)