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

Coverage report run under docker reports incorrect source #329

Closed
mcaulifn opened this issue Aug 30, 2019 · 8 comments
Closed

Coverage report run under docker reports incorrect source #329

mcaulifn opened this issue Aug 30, 2019 · 8 comments

Comments

@mcaulifn
Copy link

I am attempting to generate a coverage report for SonarQube. The project is built and tested using a container. The xml file has the source listed <source>/build/project</source> where as the actual files are under /data/jenkins/workspace/project/lambda. Is there a way to re-write the source when generating the report? python and libraries are not available outside the container as this is a Jenkins instance.

@ionelmc
Copy link
Member

ionelmc commented Sep 2, 2019

Did you try the aliasing options here https://coverage.readthedocs.io/en/v4.5.x/config.html#paths ?

@mcaulifn
Copy link
Author

mcaulifn commented Sep 3, 2019

Yes, in the .coveragec file (/data/jenkins/workspace/project/lambda/), I put the following:

[paths]
source =
    project/
    /build/*

Nothing had changed in the report.

@mcaulifn
Copy link
Author

@ionelmc any update?

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2019

So you're generating the report outside the running container? That means you're not using pytest-cov for that. How is that a pytest-cov problem?

@mcaulifn
Copy link
Author

the report is generated inside the container. it is not valid outside the container because the paths are different.

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2019

I'm afraid you need to have the sources in the actual path inside the container, unless I misunderstood how coveragepy works. Either way this ain't a bug in pytest-cov.

You could also apply a XSLT the the coverage.xml, in addition to mounting an extra path inside the cotainer.

@nedbat
Copy link
Collaborator

nedbat commented Sep 22, 2019

@mcaulifn You should open an feature request against coverage.py: when it generates the XML report, it uses the filenames as it knows them. In your case, those are names inside the container.

I'm not sure how you would like coverage.py to know what the outside-names are for the files, but we can work that out.

@mcaulifn
Copy link
Author

closing in favor of nedbat/coveragepy#597

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

No branches or pull requests

3 participants