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

Missing branches detail missing from JSON format #1425

Closed
jaltmayerpizzorno opened this issue Jul 28, 2022 · 2 comments
Closed

Missing branches detail missing from JSON format #1425

jaltmayerpizzorno opened this issue Jul 28, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jaltmayerpizzorno
Copy link

Describe the bug
Missing branches detail missing from JSON format

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using?
$ python3 --version
Python 3.9.13
  1. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
$ python3 -m coverage debug sys
-- sys -------------------------------------------------------
               coverage_version: 6.4.2
                coverage_module: /opt/homebrew/lib/python3.9/site-packages/coverage/__init__.py
                         tracer: -none-
                        CTracer: available
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: .coveragerc
                                 setup.cfg
                                 tox.ini
                                 pyproject.toml
                   configs_read: -none-
                    config_file: None
                config_contents: -none-
                      data_file: -none-
                         python: 3.9.13 (main, May 24 2022, 21:13:51) [Clang 13.1.6 (clang-1316.0.21.2)]
                       platform: macOS-12.5-arm64-arm-64bit
                 implementation: CPython
                     executable: /opt/homebrew/opt/[email protected]/bin/python3.9
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 54555
                            cwd: /Users/juan/project/slipcover
                           path: /Users/juan/project/slipcover
                                 /opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
                                 /opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9
                                 /opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
                                 /opt/homebrew/lib/python3.9/site-packages
                                 /Users/juan/project/slipcover2
                                 /Users/juan/tmp/flask/src
                    environment: HOME = /Users/juan
                   command_line: /opt/homebrew/lib/python3.9/site-packages/coverage/__main__.py debug sys
                sqlite3_version: 2.6.0
         sqlite3_sqlite_version: 3.39.2
             sqlite3_temp_store: 0
        sqlite3_compile_options: ATOMIC_INTRINSICS=1, COMPILER=clang-13.1.6, DEFAULT_AUTOVACUUM,
                                 DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4,
                                 DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096,
                                 DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS,
                                 DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2,
                                 DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2,
                                 DEFAULT_WORKER_THREADS=0, ENABLE_COLUMN_METADATA, ENABLE_FTS3,
                                 ENABLE_FTS3_PARENTHESIS, ENABLE_FTS4, ENABLE_FTS5, ENABLE_GEOPOLY,
                                 ENABLE_MATH_FUNCTIONS, ENABLE_PREUPDATE_HOOK, ENABLE_RTREE, ENABLE_SESSION,
                                 MALLOC_SOFT_LIMIT=1024, MAX_ATTACHED=10, MAX_COLUMN=2000,
                                 MAX_COMPOUND_SELECT=500, MAX_DEFAULT_PAGE_SIZE=8192, MAX_EXPR_DEPTH=1000,
                                 MAX_FUNCTION_ARG=127, MAX_LENGTH=1000000000, MAX_LIKE_PATTERN_LENGTH=50000,
                                 MAX_MMAP_SIZE=0x7fff0000, MAX_PAGE_COUNT=1073741823, MAX_PAGE_SIZE=65536,
                                 MAX_SQL_LENGTH=1000000000, MAX_TRIGGER_DEPTH=1000,
                                 MAX_VARIABLE_NUMBER=250000, MAX_VDBE_OP=250000000, MAX_WORKER_THREADS=8,
                                 MUTEX_PTHREADS, SYSTEM_MALLOC, TEMP_STORE=1, THREADSAFE=1
  1. What versions of what packages do you have installed? The output of pip freeze is helpful.
$ python3 -m pip freeze
attrs==21.4.0
click==8.1.3
coverage==6.4.2
cycler==0.11.0
-e git ssh://[email protected]/pallets/flask.git@dba2be9311d2abfd1b973c6bb578f416ee771fda#egg=Flask
fonttools==4.34.4
importlib-metadata==4.12.0
iniconfig==1.1.1
itsdangerous==2.1.2
Jinja2==3.1.2
kiwisolver==1.4.4
MarkupSafe==2.1.1
matplotlib==3.5.2
numpy==1.23.1
packaging==21.3
Pillow==9.2.0
pluggy==1.0.0
py==1.11.0
py-cpuinfo==8.0.0
pyparsing==3.0.9
pyperf==2.4.0
pytest==7.1.2
pytest-repeat==0.9.1
python-dateutil==2.8.2
six==1.16.0
-e git ssh://[email protected]/jaltmayerpizzorno/slipcover.git@1164e0d5449eae9e1b1ed4eda663475144fb1cb8#egg=slipcover
tabulate==0.8.10
tomli==2.0.1
typer==0.6.1
Werkzeug==2.2.1
zipp==3.8.1
  1. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
x = 0
if x >= 0:
    x  = 1
x  = 2
  1. What commands did you run?
$ python3 -m coverage run --branch b.py; \
   python3 -m coverage report -m; \
   python3 -m coverage json; \
   python3 -m json.tool coverage.json
Name    Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------
b.py        4      0      2      1    83%   2->4
---------------------------------------------------
TOTAL       4      0      2      1    83%
Wrote JSON report to coverage.json
{
    "meta": {
        "version": "6.4.2",
        "timestamp": "2022-07-28T13:40:37.638100",
        "branch_coverage": true,
        "show_contexts": false
    },
    "files": {
        "b.py": {
            "executed_lines": [
                1,
                2,
                3,
                4
            ],
            "summary": {
                "covered_lines": 4,
                "num_statements": 4,
                "percent_covered": 83.33333333333333,
                "percent_covered_display": "83",
                "missing_lines": 0,
                "excluded_lines": 0,
                "num_branches": 2,
                "num_partial_branches": 1,
                "covered_branches": 1,
                "missing_branches": 1
            },
            "missing_lines": [],
            "excluded_lines": []
        }
    },
    "totals": {
        "covered_lines": 4,
        "num_statements": 4,
        "percent_covered": 83.33333333333333,
        "percent_covered_display": "83",
        "missing_lines": 0,
        "excluded_lines": 0,
        "num_branches": 2,
        "num_partial_branches": 1,
        "covered_branches": 1,
        "missing_branches": 1
    }
}

Expected behavior
I'd expect the missing 2->4 branch to be shown somewhere in the JSON.

@jaltmayerpizzorno jaltmayerpizzorno added bug Something isn't working needs triage labels Jul 28, 2022
nedbat pushed a commit that referenced this issue Sep 29, 2022
Added more branches to the code whose coverage is checked.

Add branch details to json report

The json report now includes for each branch which branches have been
executed, missed and what the percentage of covered branches was.

Add exiting branch arc to json report test

Update branch details format

Executed and missing branch arcs are stored in the fields named
'executed_branches' and 'missing_branches' respectively. Both fields
contain a list of two element lists. The first element represents the
source line number and the second one the target line number. Exit
branches have their target line number set to 0.

Fix linting errors
@nedbat
Copy link
Owner

nedbat commented Sep 29, 2022

Completed as of 95195b1.

@nedbat nedbat added enhancement New feature or request and removed bug Something isn't working needs triage labels Sep 29, 2022
@nedbat nedbat closed this as completed Sep 29, 2022
@nedbat
Copy link
Owner

nedbat commented Sep 29, 2022

This is now released as part of coverage 6.5.0.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 8, 2022
Version 6.5.0 — 2022-09-29
--------------------------

- The JSON report now includes details of which branches were taken, and which
  are missing for each file. Thanks, Christoph Blessing (`pull 1438`_). Closes
  `issue 1425`_.

- Starting with coverage.py 6.2, ``class`` statements were marked as a branch.
  This wasn't right, and has been reverted, fixing `issue 1449`_. Note this
  will very slightly reduce your coverage total if you are measuring branch
  coverage.

- Packaging is now compliant with `PEP 517`_, closing `issue 1395`_.

- A new debug option ``--debug=pathmap`` shows details of the remapping of
  paths that happens during combine due to the ``[paths]`` setting.

- Fix an internal problem with caching of invalid Python parsing. Found by
  OSS-Fuzz, fixing their `bug 50381`_.

.. _bug 50381: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50381
.. _PEP 517: https://peps.python.org/pep-0517/
.. _issue 1395: nedbat/coveragepy#1395
.. _issue 1425: nedbat/coveragepy#1425
.. _pull 1438: nedbat/coveragepy#1438
.. _issue 1449: nedbat/coveragepy#1449
allenporter referenced this issue in allenporter/flux-local Feb 6, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [coverage](https://togithub.com/nedbat/coveragepy) | `==6.4.2` ->
`==7.1.0` |
[![age](https://badges.renovateapi.com/packages/pypi/coverage/7.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/coverage/7.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/coverage/7.1.0/compatibility-slim/6.4.2)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/coverage/7.1.0/confidence-slim/6.4.2)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>nedbat/coveragepy</summary>

###
[`v7.1.0`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-710--2023-01-24)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.5...7.1.0)

- Added: the debug output file can now be specified with `[run]
debug_file`
    in the configuration file.  Closes `issue 1319`\_.

- Performance: fixed a slowdown with dynamic contexts that's been around
since
6.4.3. The fix closes `issue 1538`*. Thankfully this doesn't break the
`Cython change`* that fixed `issue 972`\_. Thanks to Mathieu Kniewallner
for
    the deep investigative work and comprehensive issue report.

-   Typing: all product and test code has type annotations.

.. \_Cython
change:[https://github.com/nedbat/coveragepy/pull/1347](https://togithub.com/nedbat/coveragepy/pull/1347)7
.. \_issue
972[https://github.com/nedbat/coveragepy/issues/972](https://togithub.com/nedbat/coveragepy/issues/972)72
.. \_issue
131[https://github.com/nedbat/coveragepy/issues/1319](https://togithub.com/nedbat/coveragepy/issues/1319)319
.. \_issue
15[https://github.com/nedbat/coveragepy/issues/1538](https://togithub.com/nedbat/coveragepy/issues/1538)1538

.. \_changes\_7-0-5:

###
[`v7.0.5`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-705--2023-01-10)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.4...7.0.5)

- Fix: On Python 3.7, a file with type annotations but no `from
__future__
import annotations` would be missing statements in the coverage report.
This
    is now fixed, closing `issue 1524`\_.

.. \_issue
1524:[https://github.com/nedbat/coveragepy/issues/1524](https://togithub.com/nedbat/coveragepy/issues/1524)4

.. \_changes\_7-0-4:

###
[`v7.0.4`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-704--2023-01-07)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.3...7.0.4)

- Performance: an internal cache of file names was accidentally
disabled,
resulting in sometimes drastic reductions in performance. This is now
fixed,
closing `issue 1527`\_. Thanks to Ivan Ciuvalschii for the reproducible
test
    case.

.. \_issue
1527:[https://github.com/nedbat/coveragepy/issues/1527](https://togithub.com/nedbat/coveragepy/issues/1527)7

.. \_changes\_7-0-3:

###
[`v7.0.3`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-703--2023-01-03)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.2...7.0.3)

- Fix: when using pytest-cov or pytest-xdist, or perhaps both, the
combining
step could fail with `assert row is not None` using 7.0.2. This was due
to
a race condition that has always been possible and is still possible. In
7.0.1 and before, the error was silently swallowed by the combining
code.
Now it will produce a message "Couldn't combine data file" and ignore
the
    data file as it used to do before 7.0.2.  Closes `issue 1522`\_.

.. \_issue
1522:[https://github.com/nedbat/coveragepy/issues/1522](https://togithub.com/nedbat/coveragepy/issues/1522)2

.. \_changes\_7-0-2:

###
[`v7.0.2`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-702--2023-01-02)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.1...7.0.2)

- Fix: when using the `[run] relative_files = True` setting, a relative
    `[paths]` pattern was still being made absolute.  This is now fixed,
    closing `issue 1519`\_.

- Fix: if Python doesn't provide tomllib, then TOML configuration files
can
    only be read if coverage.py is installed with the `[toml]` extra.
Coverage.py will raise an error if TOML support is not installed when it
sees
    your settings are in a .toml file. But it didn't understand that
`[tools.coverage]` was a valid section header, so the error wasn't
reported
if you used that header, and settings were silently ignored. This is now
    fixed, closing `issue 1516`\_.

- Fix: adjusted how decorators are traced on PyPy 7.3.10, fixing `issue
1515`\_.

-   Fix: the `coverage lcov` report did not properly implement the
    `--fail-under=MIN` option.  This has been fixed.

- Refactor: added many type annotations, including a number of
refactorings.
This should not affect outward behavior, but they were a bit invasive in
some
    places, so keep your eyes peeled for oddities.

- Refactor: removed the vestigial and long untested support for Jython
and
    IronPython.

.. \_issue
1515:[https://github.com/nedbat/coveragepy/issues/1515](https://togithub.com/nedbat/coveragepy/issues/1515)5
.. \_issue
1516[https://github.com/nedbat/coveragepy/issues/1516](https://togithub.com/nedbat/coveragepy/issues/1516)16
.. \_issue
151[https://github.com/nedbat/coveragepy/issues/1519](https://togithub.com/nedbat/coveragepy/issues/1519)519

.. \_changes\_7-0-1:

###
[`v7.0.1`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-701--2022-12-23)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/7.0.0...7.0.1)

- When checking if a file mapping resolved to a file that exists, we
weren't
considering files in .whl files. This is now fixed, closing `issue
1511`\_.

- File pattern rules were too strict, forbidding plus signs and curly
braces in
directory and file names. This is now fixed, closing `issue 1513`\_.

-   Unusual Unicode or control characters in source files could prevent
    reporting.  This is now fixed, closing `issue 1512`\_.

- The PyPy wheel now installs on PyPy 3.7, 3.8, and 3.9, closing `issue
1510`\_.

.. \_issue
1510:[https://github.com/nedbat/coveragepy/issues/1510](https://togithub.com/nedbat/coveragepy/issues/1510)0
.. \_issue
1511[https://github.com/nedbat/coveragepy/issues/1511](https://togithub.com/nedbat/coveragepy/issues/1511)11
.. \_issue
151[https://github.com/nedbat/coveragepy/issues/1512](https://togithub.com/nedbat/coveragepy/issues/1512)512
.. \_issue
15[https://github.com/nedbat/coveragepy/issues/1513](https://togithub.com/nedbat/coveragepy/issues/1513)1513

.. \_changes\_7-0-0:

###
[`v7.0.0`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-700--2022-12-18)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/6.5.0...7.0.0)

Nothing new beyond 7.0.0b1.

.. \_changes\_7-0-0b1:

###
[`v6.5.0`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-650--2022-09-29)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/6.4.4...6.5.0)

- The JSON report now includes details of which branches were taken, and
which
are missing for each file. Thanks, `Christoph Blessing <pull 1438_>`*.
Closes
    `issue 1425`*.

- Starting with coverage.py 6.2, `class` statements were marked as a
branch.
This wasn't right, and has been reverted, fixing `issue 1449`\_. Note
this
will very slightly reduce your coverage total if you are measuring
branch
    coverage.

-   Packaging is now compliant with `PEP 517`*, closing `issue 1395`*.

- A new debug option `--debug=pathmap` shows details of the remapping of
    paths that happens during combine due to the `[paths]` setting.

- Fix an internal problem with caching of invalid Python parsing. Found
by
    OSS-Fuzz, fixing their `bug 50381`\_.

.. \_bug 50381:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50381
.. \_PEP 517: https://peps.python.org/pep-0517/
.. \_issue
139[https://github.com/nedbat/coveragepy/issues/1395](https://togithub.com/nedbat/coveragepy/issues/1395)395
.. \_issue
14[https://github.com/nedbat/coveragepy/issues/1425](https://togithub.com/nedbat/coveragepy/issues/1425)1425
.. \_issue
1[https://github.com/nedbat/coveragepy/issues/1449](https://togithub.com/nedbat/coveragepy/issues/1449)/1449
.. \_pull
[https://github.com/nedbat/coveragepy/pull/1438](https://togithub.com/nedbat/coveragepy/pull/1438)l/1438

.. \_changes\_6-4-4:

###
[`v6.4.4`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-644--2022-08-16)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/6.4.3...6.4.4)

-   Wheels are now provided for Python 3.11.

.. \_changes\_6-4-3:

###
[`v6.4.3`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-643--2022-08-06)

[Compare
Source](https://togithub.com/nedbat/coveragepy/compare/6.4.2...6.4.3)

- Fix a failure when combining data files if the file names contained
glob-like
patterns. Thanks, `Michael Krebs and Benjamin Schubert <pull 1405_>`\_.

- Fix a messaging failure when combining Windows data files on a
different
drive than the current directory, closing `issue 1428`*. Thanks,
`Lorenzo
    Micò <pull 1430_>`*.

- Fix path calculations when running in the root directory, as you might
do in
    a Docker container. Thanks `Arthur Rio <pull 1403_>`\_.

- Filtering in the HTML report wouldn't work when reloading the index
page.
    This is now fixed.  Thanks, `Marc Legendre <pull 1413_>`\_.

- Fix a problem with Cython code measurement, closing `issue 972`*.
Thanks,
    `Matus Valo <pull 1347_>`*.

.. \_issue
972:[https://github.com/nedbat/coveragepy/issues/972](https://togithub.com/nedbat/coveragepy/issues/972)2
.. \_issue
1428[https://github.com/nedbat/coveragepy/issues/1428](https://togithub.com/nedbat/coveragepy/issues/1428)28
.. \_pull
134[https://github.com/nedbat/coveragepy/pull/1347](https://togithub.com/nedbat/coveragepy/pull/1347)347
.. \_pull
14[https://github.com/nedbat/coveragepy/issues/1403](https://togithub.com/nedbat/coveragepy/issues/1403)1403
.. \_pull
1[https://github.com/nedbat/coveragepy/issues/1405](https://togithub.com/nedbat/coveragepy/issues/1405)/1405
.. \_pull
[https://github.com/nedbat/coveragepy/issues/1413](https://togithub.com/nedbat/coveragepy/issues/1413)s/1413
..
\_pull[https://github.com/nedbat/coveragepy/pull/1430](https://togithub.com/nedbat/coveragepy/pull/1430)ll/1430

.. \_changes\_6-4-2:

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMjQuMiIsInVwZGF0ZWRJblZlciI6IjM0LjEyNC4yIn0=-->

Co-authored-by: renovate[bot] <29139614 renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants