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

No data sent to Coveralls casued by absolute paths in cobertura file #199

Closed
Martomate opened this issue Sep 3, 2022 · 7 comments
Closed
Assignees

Comments

@Martomate
Copy link

Martomate commented Sep 3, 2022

Environment

Scala 3.2.0, sbt-scoverage 2.0.2, sbt-coveralls 1.3.2

Problem

No coverage data is sent to Coveralls

Possible cause

The cobertura.xml file contains absolute paths for the class filenames, which results in sbt-coveralls not finding any source files.

This happens on this line, where the relativePath is not relative:

This is likely caused by the new scoverage version for Scala 3, where there were some changes to the cobertura.xml file. It now starts like this:

<?xml version="1.0"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage 
line-rate="0.29" lines-valid="7499" lines-covered="2198" branches-valid="593" branches-covered="175" branch-rate="0.30" complexity="0" version="1.0" timestamp="1662191703030">
    <sources>
        <source>--source</source>
        <source>/Users/martin/git/myproject/src/main/scala</source>
    </sources>
    <packages>
        <package name="ai" line-rate="0.00" branch-rate="0.00" complexity="0">
            <classes>
                <class 
                name="a.MyClass" filename="/Users/martin/git/myproject/src/main/scala/a/MyClass.scala" line-rate="0.00" branch-rate="0.00" complexity="0">
                    <methods>
                        <method name="a/MyClass/myFunction" signature="()V" line-rate="0.00" branch-rate="0.00" complexity="0">
                            <lines>
                                <line number="17" hits="0" branch="false"/>
@rolandtritsch
Copy link
Member

Hi @Martomate. I can reproduce this.

Hi @ckipp01. This looks like a bug. If it is ok with you, I will take a look at this. I think these paths should be relative (like the paths in all the other output files).

@ckipp01
Copy link
Member

ckipp01 commented Sep 6, 2022

Hi @ckipp01. This looks like a bug. If it is ok with you, I will take a look at this. I think these paths should be relative (like the paths in all the other output files).

For sure!

@rolandtritsch
Copy link
Member

Proposed fix - scoverage/scalac-scoverage-plugin#497

@rolandtritsch
Copy link
Member

@ckipp01 After this/the fix is merged and we have a new version of scalac-scoverage-plugin we need to rebuild/publish a new version of sbt-coverage.

@ckipp01
Copy link
Member

ckipp01 commented Sep 10, 2022

@ckipp01 After this/the fix is merged and we have a new version of scalac-scoverage-plugin we need to rebuild/publish a new version of sbt-coverage.

2.12.17 and 2.13.9 are scheduled for release this week, so I'll probably wait for those, and then cut the release which will include the fix.

@Martomate
Copy link
Author

This seems to have been fixed in sbt-scoverage 2.0.4, and I can confirm that it now works! Thanks a lot for fixing this so quickly!

@Falmarri
Copy link

Why was the fix for this to make this relative, rather than just use the existing absolute file path? Right now this is a heuristic to find the file. There can be multiple file names that have the same relative path in the source directories, especially on aggregated builds between subprojects.

scoverage/scalac-scoverage-plugin#582

It seems absurd to not just check to see if the path is absolute and use that directly rather than try to search through the list of source directories to find a path that matches.

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

4 participants