summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2020-06-17 16:23:07 +0000
committerXavier-Do <xdo@odoo.com>2020-07-09 10:01:45 +0000
commitdbf40606490f43614d5555b9b6acf168266f05d0 (patch)
tree423b7cc4b27bc3be0293210451095ffe668fc16d /odoo/modules/loading.py
parentf572fa720e6d8837b1b9e3e7d32010b88cefac8a (diff)
[IMP] tests: allow to run at_install tests without update
Debugging/improvement of an at install test may be tedious because of the need to update the module, spending most of the time checking tables and xml file. 1. This commit proposes to allow to execute test without installing or updating a module. The test is still executed during the loading, and the behavior should be close to an execution of tests during an update. Co-authored-by rco-odoo <rco@odoo.com> 2. keep previous behavior if -i or -u is given Three solutions were possible: - The clean one that changes dev habits. When test-enable or test_tags is given, all tests are always executed, a test_tags is needed to select tests to execute: Example: `-u module --test_enable` becomes `-u module --test-tags /module` to keep the same behaviour This solution is the simplest, and executed tests does not depends on database already installed modules. - The conservative solution. When giving -i or -u, the behavior stays the same as before. When giving test-enable without -i/-u, test are executed on all installed modules. - The intermediate solution: When no test_tags is given but a -i and -u is given, only the given modules are tested. This is quite close to the second solution except that a -i module on a new database won't test all dependencies on the first install. The chosen solution is the second one to minimize changes on dev old habits, only an almost unused feature is impacted: using test-enable without any -i or -u. Before this pr only post install tests were executed in this case. Now at_install tests are also executed. This combination is actually used by runbot to execute post_install test in parallel, but a `--test-tags -at_install` tag is given so nothing to worry about here. closes odoo/odoo#53499 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/modules/loading.py')
-rw-r--r--odoo/modules/loading.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index 070bd325d18..af2cbe72f20 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -241,9 +241,10 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
overwrite = odoo.tools.config["overwrite_existing_translations"]
module.with_context(overwrite=overwrite)._update_translations()
- if package.name is not None:
- registry._init_modules.add(package.name)
+ if package.name is not None:
+ registry._init_modules.add(package.name)
+ if needs_update:
if new_install:
post_init = package.info.get('post_init_hook')
if post_init:
@@ -258,15 +259,20 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
# (separately in their own transaction)
cr.commit()
- if tools.config.options['test_enable']:
- report.record_result(load_test(idref, mode))
- # Python tests
- env['ir.http']._clear_routing_map() # force routing map to be rebuilt
- report.record_result(odoo.modules.module.run_unit_tests(module_name))
- # tests may have reset the environment
- env = api.Environment(cr, SUPERUSER_ID, {})
- module = env['ir.module.module'].browse(module_id)
+ updating = tools.config.options['init'] or tools.config.options['update']
+ if tools.config.options['test_enable'] and (needs_update or not updating):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ if not needs_update:
+ registry.setup_models(cr)
+ report.record_result(load_test(idref, mode))
+ # Python tests
+ env['ir.http']._clear_routing_map() # force routing map to be rebuilt
+ report.record_result(odoo.modules.module.run_unit_tests(module_name))
+ # tests may have reset the environment
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ module = env['ir.module.module'].browse(module_id)
+ if needs_update:
processed_modules.append(package.name)
ver = adapt_version(package.data['version'])
@@ -281,9 +287,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
delattr(package, kind)
module.flush()
- if package.name is not None:
- registry._init_modules.add(package.name)
-
_logger.log(module_log_level, "Module %s loaded in %.2fs, %s queries (+%s extra)",
module_name,
time.time() - module_t0,