mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
wip
This commit is contained in:
parent
383352d88e
commit
26a4737ba5
@ -288,12 +288,9 @@ class ConfigStep(models.Model):
|
|||||||
def _make_python_ctx(self, build):
|
def _make_python_ctx(self, build):
|
||||||
return {
|
return {
|
||||||
'self': self,
|
'self': self,
|
||||||
# 'fields': fields,
|
|
||||||
# 'models': models,
|
|
||||||
'build': build,
|
'build': build,
|
||||||
'_logger': _logger,
|
'_logger': _logger,
|
||||||
'log_path': build._path('logs', '%s.txt' % self.name),
|
'log_path': build._path('logs', '%s.txt' % self.name),
|
||||||
'glob': glob.glob,
|
|
||||||
'Command': Command,
|
'Command': Command,
|
||||||
're': ReProxy,
|
're': ReProxy,
|
||||||
'grep': grep,
|
'grep': grep,
|
||||||
@ -311,15 +308,19 @@ class ConfigStep(models.Model):
|
|||||||
if run and callable(run):
|
if run and callable(run):
|
||||||
return run()
|
return run()
|
||||||
return eval_ctx.get('docker_params')
|
return eval_ctx.get('docker_params')
|
||||||
except ValueError as e:
|
except RunbotException as e:
|
||||||
save_eval_value_error_re = r'<class \'odoo.addons.runbot.models.repo.RunbotException\'>: "(.*)" while evaluating\n.*'
|
|
||||||
message = e.args[0]
|
message = e.args[0]
|
||||||
groups = re.match(save_eval_value_error_re, message)
|
build._log("run", f'A runbot exception occured:\n{message}', level='ERROR')
|
||||||
if groups:
|
build._kill(result='ko')
|
||||||
build._log("run", groups[1], level='ERROR')
|
#except ValueError as e:
|
||||||
build._kill(result='ko')
|
# save_eval_value_error_re = r'''<class 'odoo.addons.runbot.commona.RunbotException'>: "(.*)" while evaluating\n.*'''
|
||||||
else:
|
# message = e.args[0]
|
||||||
raise
|
# groups = re.match(save_eval_value_error_re, message)
|
||||||
|
# if groups:
|
||||||
|
# build._log("run", groups[1], level='ERROR')
|
||||||
|
# build._kill(result='ko')
|
||||||
|
# else:
|
||||||
|
# raise
|
||||||
|
|
||||||
def _is_docker_step(self):
|
def _is_docker_step(self):
|
||||||
if not self:
|
if not self:
|
||||||
|
@ -388,7 +388,8 @@ class TestBuildResult(RunbotCase):
|
|||||||
self.assertEqual('waiting', build1.global_state)
|
self.assertEqual('waiting', build1.global_state)
|
||||||
self.assertEqual('testing', build1_1.global_state)
|
self.assertEqual('testing', build1_1.global_state)
|
||||||
|
|
||||||
# with self.assertQueries([]): # write the same value, no update should be triggered
|
#with self.assertQueries(['''UPDATE "runbot_build" SET "global_state" = %s, "write_date" = %s, "write_uid" = %s WHERE id IN %s''']):
|
||||||
|
|
||||||
build1.local_state = 'done'
|
build1.local_state = 'done'
|
||||||
build1.flush_recordset()
|
build1.flush_recordset()
|
||||||
|
|
||||||
|
@ -588,6 +588,28 @@ def run():
|
|||||||
retult = config_step._run_python(self.parent_build)
|
retult = config_step._run_python(self.parent_build)
|
||||||
self.assertEqual(retult, {'a': 'b'})
|
self.assertEqual(retult, {'a': 'b'})
|
||||||
|
|
||||||
|
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
||||||
|
def test_run_python_exception(self, mock_checkout):
|
||||||
|
"""minimal test for python steps. Also test that `-d` in cmd creates a database"""
|
||||||
|
|
||||||
|
def raise_runbot_exception():
|
||||||
|
raise RunbotException('Nope')
|
||||||
|
|
||||||
|
mock_checkout.side_effect = raise_runbot_exception
|
||||||
|
test_code = """
|
||||||
|
def run():
|
||||||
|
build._checkout()
|
||||||
|
"""
|
||||||
|
config_step = self.ConfigStep.create({
|
||||||
|
'name': 'default',
|
||||||
|
'job_type': 'python',
|
||||||
|
'python_code': test_code,
|
||||||
|
})
|
||||||
|
|
||||||
|
config_step._run_python(self.parent_build)
|
||||||
|
self.assertEqual(self.parent_build.log_ids.mapped('message'), ['A runbot exception occured:\nNope'])
|
||||||
|
self.assertEqual(self.parent_build.log_ids.mapped('level'), ['ERROR'])
|
||||||
|
|
||||||
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
||||||
def test_sub_command(self, mock_checkout):
|
def test_sub_command(self, mock_checkout):
|
||||||
config_step = self.ConfigStep.create({
|
config_step = self.ConfigStep.create({
|
||||||
|
Loading…
Reference in New Issue
Block a user