aconrad / pycobertura

A code coverage diff tool for Cobertura reports
MIT License
116 stars 39 forks source link

Fix total values when ignore regex used #176

Closed danctorres closed 8 months ago

danctorres commented 8 months ago

Expected Behavior: The report should display the total values (stmts, miss, and cover), calculated for all files excluding those specified by the ignore_regex.

Actual Behavior: Previously, when using ignore_regex to exclude files, the report's total values were incorrect. The values remained the same whether the ignore_regex argument was passed or not.

Steps to Reproduce: ~/pycobertura > pycobertura show --ignore-regex ".*Main|.*ISorted" --format markdown tests/cobertura.xml

Report Before Fix:

| Filename                 |   Stmts |   Miss | Cover   | Missing   |
|--------------------------|---------|--------|---------|-----------|
| search/BinarySearch.java |      12 |      1 | 91.67%  | 24        |
| search/LinearSearch.java |       7 |      2 | 71.43%  | 19-24     |
| TOTAL                    |      34 |      3 | 90.00%  |           |

Changes:

Result: After the fix, the total values are now calculated correctly, reflected by the following report, generated with the same command.

Report After Fix:

| Filename                 |   Stmts |   Miss | Cover   | Missing   |
|--------------------------|---------|--------|---------|-----------|
| search/BinarySearch.java |      12 |      1 | 91.67%  | 24        |
| search/LinearSearch.java |       7 |      2 | 71.43%  | 19-24     |
| TOTAL                    |      19 |      3 | 84.21%  |           |
aconrad commented 8 months ago

Thanks @danctorres, much appreciated! I'll take a look at it soon.

Can you update the PR description to show the before/after to better understand what you observed that looked wrong?

danctorres commented 8 months ago

Thanks @danctorres, much appreciated! I'll take a look at it soon.

Can you update the PR description to show the before/after to better understand what you observed that looked wrong?

@aconrad updated the description, hope it helps

aconrad commented 8 months ago

v3.3.1