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

[good-first-issue] Incomplete Cobertura XML spec support #17689

Closed
webknjaz opened this issue Aug 19, 2024 · 2 comments · Fixed by #17738
Closed

[good-first-issue] Incomplete Cobertura XML spec support #17689

webknjaz opened this issue Aug 19, 2024 · 2 comments · Fixed by #17738
Labels
bug mypy got something wrong

Comments

@webknjaz
Copy link

Bug Report

The cobetura.xml file generated does not contain the lines-covered and lines-valid attributes. According to https://stackoverflow.com/a/71116722/595220, the spec is at https://github.com/cobertura/web/blob/master/htdocs/xml/coverage-04.dtd which has

<!ATTLIST coverage lines-covered    CDATA #REQUIRED>
<!ATTLIST coverage lines-valid      CDATA #REQUIRED>

I haven't checked ll

To Reproduce

Add --cobertura-xml-report to any MyPy invocation, grab the resulting XML file, and feed it to irongut/CodeCoverageSummary @ GHA.

Expected Behavior

Spec-compliant tools shouldn't crash when presented with a MyPy-produced coverage XML report advertising its compatibility with the Cobertura standard.

Actual Behavior

Tools like the irongut/CodeCoverageSummary action error out because of missing required XML attributes: irongut/CodeCoverageSummary#324. It fails upon checking for the presence of the lines-covered attribute in the <coverage> node with "Overall lines covered not found" in this case. But I looked further into their source code, and I saw that it'd also choke on missing lines-valid with "Overall lines valid not found".

I haven't checked any further but it might be a good idea to check the implementation against anything marked as #REQUIRED in said DTD spec.

Extra research

Looking into https://github.com/python/mypy/blob/fe15ee6/mypy/report.py#L597, it seems to me that the values that could be mapped to the missing attributes are already present in the class and the mapping should be straightforward:

self.total_lines -> lines-valid
self.covered_lines -> lines-covered
@x612skm
Copy link
Contributor

x612skm commented Aug 30, 2024

Hey, I'm working into it! Thanks!

@webknjaz
Copy link
Author

webknjaz commented Sep 5, 2024

@hauntsaninja could you please assign this issue to @x612skm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants