Skip to content

Coverage combine chokes on coverage databases from different platforms #2266

Description

@creiter64

Describe the bug
I want to combine coverage data from pytest runs performed on Linux and on Windows.
I execute them with the pytest-cov plugin and can report the coverage for each platform individually, but if I use coverage combine on Linux to combine the coverage databases to get the common code coverage, it reports:

No source for code: 'src\<module>\__init__.py'

If you look closely you can see that the path contains backslashes, which are from the Windows run and this path obviously doesn't exist on the Linux system, where the code coverage data should be combined and a report generated.

It seems coverage.py stores paths in the native way of the platform, which I confirmed by analyzing the database files:

.coverage.windows the table file contains:

src\<module>\__init__.py

.coverage.linux the table file contains:

src/<module>/__init__.py

To Reproduce

  • Execute a code coverage run on Linux and Windows platforms from the root of a cross-platform Python module
  • Try to merge the coverage using coverage combine ...

Answer the questions below:

  1. What version of Python are you using?
  • CPython 3.11.14
  1. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
  • coverage==7.15.2
  1. What versions of what packages do you have installed? The output of pip freeze is helpful.
  2. 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.
  3. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!

Expected behavior

I expect coverage combine to be able to combine code coverage data from different platforms. It should be able to normalize the paths to the current platform, so that coverage html and coverage xml can work on the combined data.

Additional context

It might make sense to use pathlib to store coverage data in Posix format in the database and convert on Windows if needed.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions