mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: improve test-tags support
The current post_install build mecanism is using extra params to give test-tags. Unfortunately this disables the support for auto tags and this have to be done manually. This means that auto tags are in the build extra-params and not dynamic at rebuild of a post_install. Also, using extraparams in the post install creation was removing extra_params comming from custom trigger. With this commit, the test-tags can be given inside config_data and will be combined with config step test-tags and auto-tags. This was an opportunity to simplify the logic. This commit also fixes the test_install_tags that was broken.
This commit is contained in:
parent
2ad188201b
commit
e3d87b5b5d
@ -435,25 +435,27 @@ class ConfigStep(models.Model):
|
|||||||
cmd.extend(['--test-enable'])
|
cmd.extend(['--test-enable'])
|
||||||
else:
|
else:
|
||||||
build._log('test_all', 'Installing modules without testing', level='WARNING')
|
build._log('test_all', 'Installing modules without testing', level='WARNING')
|
||||||
|
|
||||||
test_tags_in_extra = '--test-tags' in extra_params
|
test_tags_in_extra = '--test-tags' in extra_params
|
||||||
|
|
||||||
disable_auto_tags = build.params_id.config_data.get('disable_auto_tags', False)
|
if (self.test_enable or self.test_tags) and "--test-tags" in available_options and not test_tags_in_extra:
|
||||||
if self.test_tags or test_tags_in_extra:
|
test_tags = []
|
||||||
if "--test-tags" in available_options:
|
custom_tags = build.params_id.config_data.get('test_tags')
|
||||||
if not test_tags_in_extra:
|
if custom_tags:
|
||||||
test_tags = self.test_tags.replace(' ', '')
|
test_tags += custom_tags.replace(' ', '').split(',')
|
||||||
if self.enable_auto_tags and not disable_auto_tags:
|
if self.test_tags:
|
||||||
auto_tags = self.env['runbot.build.error'].disabling_tags()
|
test_tags += self.test_tags.replace(' ', '').split(',')
|
||||||
test_tags = ','.join(test_tags.split(',') + auto_tags)
|
if self.enable_auto_tags and not build.params_id.config_data.get('disable_auto_tags', False):
|
||||||
cmd.extend(['--test-tags', test_tags])
|
if grep(config_path, "[/module][:class]"):
|
||||||
else:
|
auto_tags = self.env['runbot.build.error'].disabling_tags()
|
||||||
build._log('test_all', 'Test tags given but not supported')
|
if auto_tags:
|
||||||
elif self.enable_auto_tags and self.test_enable and not disable_auto_tags:
|
test_tags += auto_tags
|
||||||
if grep(config_path, "[/module][:class]"):
|
|
||||||
auto_tags = self.env['runbot.build.error'].disabling_tags()
|
test_tags = [test_tag for test_tag in test_tags if test_tag]
|
||||||
if auto_tags:
|
if test_tags:
|
||||||
test_tags = ','.join(auto_tags)
|
cmd.extend(['--test-tags', ','.join(test_tags)])
|
||||||
cmd.extend(['--test-tags', test_tags])
|
elif test_tags_in_extra or self.test_tags and "--test-tags" not in available_options:
|
||||||
|
build._log('test_all', 'Test tags given but not supported')
|
||||||
|
|
||||||
if "--screenshots" in available_options:
|
if "--screenshots" in available_options:
|
||||||
cmd.add_config_tuple('screenshots', '/data/build/tests')
|
cmd.add_config_tuple('screenshots', '/data/build/tests')
|
||||||
|
@ -404,8 +404,15 @@ class TestBuildConfigStep(TestBuildConfigStepCommon):
|
|||||||
|
|
||||||
config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
||||||
|
|
||||||
|
def get_test_tags(self, params):
|
||||||
|
cmds = params['cmd'].build().split(' && ')
|
||||||
|
self.assertEqual(cmds[1].split(' server/server.py')[0], 'python3')
|
||||||
|
return cmds[1].split('--test-tags ')[1].split(' ')[0]
|
||||||
|
|
||||||
|
@patch('odoo.addons.runbot.models.build.BuildResult.parse_config')
|
||||||
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
||||||
def test_install_tags(self, mock_checkout):
|
def test_install_tags(self, mock_checkout, parse_config):
|
||||||
|
parse_config.return_value = {'--test-enable', '--test-tags'}
|
||||||
config_step = self.ConfigStep.create({
|
config_step = self.ConfigStep.create({
|
||||||
'name': 'all',
|
'name': 'all',
|
||||||
'job_type': 'install_odoo',
|
'job_type': 'install_odoo',
|
||||||
@ -417,26 +424,36 @@ class TestBuildConfigStep(TestBuildConfigStepCommon):
|
|||||||
'random': True,
|
'random': True,
|
||||||
'test_tags': ':otherclass.othertest'
|
'test_tags': ':otherclass.othertest'
|
||||||
})
|
})
|
||||||
|
params = config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
||||||
def docker_run(cmd, *args, **kwargs):
|
tags = self.get_test_tags(params)
|
||||||
cmds = cmd.build().split(' && ')
|
self.assertEqual(tags, '/module,:class.method')
|
||||||
self.assertEqual(cmds[1].split(' server/server.py')[0], 'python3')
|
|
||||||
tags = cmds[1].split('--test-tags ')[1].split(' ')[0]
|
|
||||||
self.assertEqual(tags, '/module,:class.method')
|
|
||||||
|
|
||||||
self.patchers['docker_run'].side_effect = docker_run
|
|
||||||
config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
|
||||||
|
|
||||||
config_step.enable_auto_tags = True
|
config_step.enable_auto_tags = True
|
||||||
|
params = config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
||||||
|
tags = self.get_test_tags(params)
|
||||||
|
self.assertEqual(tags, '/module,:class.method,-:otherclass.othertest')
|
||||||
|
|
||||||
def docker_run2(cmd, *args, **kwargs):
|
@patch('odoo.addons.runbot.models.build.BuildResult.parse_config')
|
||||||
cmds = cmd.build().split(' && ')
|
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
||||||
self.assertEqual(cmds[1].split(' server/server.py')[0], 'python3')
|
def test_install_custom_tags(self, mock_checkout, parse_config):
|
||||||
tags = cmds[1].split('--test-tags ')[1].split(' ')[0]
|
parse_config.return_value = {'--test-enable', '--test-tags'}
|
||||||
self.assertEqual(tags, '/module,:class.method,-:otherclass.othertest')
|
config_step = self.ConfigStep.create({
|
||||||
|
'name': 'all',
|
||||||
|
'job_type': 'install_odoo',
|
||||||
|
'enable_auto_tags': True,
|
||||||
|
})
|
||||||
|
self.env['runbot.build.error'].create({
|
||||||
|
'content': 'foo',
|
||||||
|
'random': True,
|
||||||
|
'test_tags': ':otherclass.othertest'
|
||||||
|
})
|
||||||
|
|
||||||
|
child = self.parent_build._add_child({'config_data': {'test_tags': '-at_install,/module1,/module2'}})
|
||||||
|
|
||||||
|
params = config_step._run_install_odoo(child, 'dev/null/logpath')
|
||||||
|
tags = self.get_test_tags(params)
|
||||||
|
self.assertEqual(tags, '-at_install,/module1,/module2,-:otherclass.othertest')
|
||||||
|
|
||||||
self.patchers['docker_run'].side_effect = docker_run2
|
|
||||||
config_step._run_install_odoo(self.parent_build, 'dev/null/logpath')
|
|
||||||
|
|
||||||
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
|
||||||
def test_db_name(self, mock_checkout):
|
def test_db_name(self, mock_checkout):
|
||||||
|
Loading…
Reference in New Issue
Block a user