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

Generate coverage data using relative paths #135

Closed
MarkKoz opened this issue Dec 28, 2021 · 2 comments · Fixed by #136
Closed

Generate coverage data using relative paths #135

MarkKoz opened this issue Dec 28, 2021 · 2 comments · Fixed by #136
Assignees
Labels
area: dev env Related to the development environment and its setup area: tests Related to tests (e.g. unit tests) priority: 2 - normal type: feature New feature or request

Comments

@MarkKoz
Copy link
Member

MarkKoz commented Dec 28, 2021

Currently, coverage data is generated with absolute paths. This means that if the coverage file is moved across machines, the source code must be in the exact same location. The current workaround is to configure Docker to mount the host's code to the same exact directory within the container. However, this doesn't work for Windows machines since the host's path is not compatible on the Linux container.

The relative_files = true setting can be added to .coveragerc to fix this.

Note that coverage seems to rely on the correct file separator being used when generating coverage reports and combining data. In practice, this means that a Windows host will be unable to generate coverage reports since the data coming from the container will have paths with forward slashes. Until this is addressed by coverage.py, the current workaround for Windows users will be to generate coverage reports within the container. This should work for coverage report; unsure about other formats such as HTML.

@MarkKoz MarkKoz added type: feature New feature or request area: tests Related to tests (e.g. unit tests) area: dev env Related to the development environment and its setup priority: 2 - normal labels Dec 28, 2021
@MarkKoz MarkKoz self-assigned this Dec 28, 2021
@onerandomusername
Copy link
Contributor

Is there an issue on coverage.py's repo as this sounds like a bug?

@MarkKoz
Copy link
Member Author

MarkKoz commented Dec 28, 2021

Yes, sort of nedbat/coveragepy#991

MarkKoz added a commit that referenced this issue Dec 28, 2021
Fix paths being mismatched when trying to combine coverage data from
the matrix jobs in CI. Also remove the reliance on the container needing
to mount the host's files to the same directory during local testing.

Fix #135
MarkKoz added a commit that referenced this issue Dec 28, 2021
Also remove the reliance on the container needing to mount the host's
files to the same directory during local testing.

Fix #135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dev env Related to the development environment and its setup area: tests Related to tests (e.g. unit tests) priority: 2 - normal type: feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants