Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] odoo-tester: use diff-cover to measure changed code coverage #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidmcgaw
Copy link

@davidmcgaw davidmcgaw commented Jul 29, 2019

Changes I made to docker files:

  • install the diff-cover package

  • The sub-folders from udes-open are copied to the docker image. However this excludes the .git folder, which is used by diff-cover to determine code changes - solution: copy the parent folder.

  • diff-cover needs coverage data to be collected when the test is run relative to the "root" folder (that contains the .git folder):

  • All the coverage & diff-cover commands needs to be run from the "root" directory - solution: change to the "root" folder before running

  • The coverage commands create files in the "root" directory which require write permissions - solution: update permissions on the root folder to allow coverage data to be written

This is connected to another PR (in udes-open: github.com/unipartdigital/udes-open/pull/229) with the change:

  • Copy the parent folder changes the location of modules. There is some code to identify modules which are now wrong - solution: update the code to look for modules.

Below is an example of the results of calling "diff-cover coverage.xml":

-------------
Diff Coverage
Diff: origin/master...HEAD, staged and unstaged changes
-------------
addons/service_job/models/sale_order.py (0.0%): Missing lines 26,31
addons/service_job/models/servicejob.py (66.7%): Missing lines 982
-------------
Total:   5 lines
Missing: 3 lines
Coverage: 40%
-------------

Each file with changes in the diff is listed along with:

  • the percentage of the changed lines of code that are executed tests
  • a list of the lines of code that are not hit (if the percentage is <100%)

Also there is a summary of changed lines and the number of lines that are executed across all the files in the diff.

odoo-wrapper Outdated Show resolved Hide resolved
Copy link
Owner

@mcb30 mcb30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please match the existing commit message format

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
Installs and set up diff-cover package:
Diff-cover combines a coverage xml file. This requires "git diff"
so requires a git repo.

Changes:
* Add in a dependency on diff-cover
* Copy whole udes-open folder including .git as well as addons
* Give odoo user write access to the git repo
* Generate coverage xml and run diff-cover from the git repo

Signed-off-by: davidmcgaw <dmcgaw@unipart.io>
@davidmcgaw davidmcgaw changed the title [WIP] install diff-cover and call it after running tests [WIP] odoo-tester: use diff-cover to measure changed code coverage Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants