From 1449937e0056021febdffdfd4a6538604d0860be Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 27 Oct 2022 11:25:25 +0200 Subject: [PATCH] [ADD] mergebot: support for coverage during tests Runs the test instances of Odoo using `coverage` in parallel mode. - useful for finding out under-tested parts of the code - because it only instruments mergeport/forwardport, and the tests do so much IO, the wallclock performance impacts are minimal (~2% increase with branch coverage analysis, for an increase in CPU of ~20%, for the entire testsuite) - for reporting, the scattered coverage reports need to be aggregated using `coverage combine`, followed by rendering with `coverage html`, these work out of the box, no parameterization is necessary - coverage does not run on the test suite, only the modules under test --- conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conftest.py b/conftest.py index 8e9a7e66..e915632a 100644 --- a/conftest.py +++ b/conftest.py @@ -76,6 +76,7 @@ def pytest_addoption(parser): parser.addoption('--addons-path') parser.addoption("--no-delete", action="store_true", help="Don't delete repo after a failed run") parser.addoption('--log-github', action='store_true') + parser.addoption('--coverage', action='store_true') parser.addoption( '--tunnel', action="store", type="choice", choices=['', 'ngrok', 'localtunnel'], default='', @@ -372,7 +373,13 @@ def server(request, db, port, module, dummy_addons_path, tmpdir): request.config.getoption('--addons-path'), dummy_addons_path, ])) + + cov = [] + if request.config.getoption('--coverage'): + cov = ['coverage', 'run', '-p', '--source=odoo.addons.runbot_merge,odoo.addons.forwardport', '--branch'] + p = subprocess.Popen([ + *cov, 'odoo', '--http-port', str(port), '--addons-path', addons_path, '-d', db,