-
Notifications
You must be signed in to change notification settings - Fork 123
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
Line number N is greater than the source file X size #98
Comments
I got something working in the end; I guess most of my problem was trying to use Jacoco / Cobertura directly on Scala code. I was able to make things work by instead using Scoverage to output a Cobertura-formatted report. It still feels like the failure I was seeing points to a bug somewhere in either this plugin or jacoco and cobertura:
For future travelers, here is a |
@ryan-williams thanks a lot for very thorough testing. I ran your sample project and looked the jacoco report file which is parsed by the plugin. The relevant parts look like this: <sourcefile name="B.scala">
<line nr="3" mi="116" ci="0" mb="16" cb="0"/>
<line nr="4" mi="7" ci="0" mb="0" cb="0"/>
<line nr="7" mi="5" ci="0" mb="0" cb="0"/>
<counter type="INSTRUCTION" missed="139" covered="0"/>
<counter type="BRANCH" missed="16" covered="0"/>
<counter type="LINE" missed="3" covered="0"/>
<counter type="COMPLEXITY" missed="29" covered="0"/>
<counter type="METHOD" missed="21" covered="0"/>
<counter type="CLASS" missed="2" covered="0"/>
</sourcefile>
<sourcefile name="A.scala">
<line nr="7" mi="122" ci="0" mb="16" cb="0"/>
<counter type="INSTRUCTION" missed="133" covered="0"/>
<counter type="BRANCH" missed="16" covered="0"/>
<counter type="LINE" missed="1" covered="0"/>
<counter type="COMPLEXITY" missed="28" covered="0"/>
<counter type="METHOD" missed="20" covered="0"/>
<counter type="CLASS" missed="2" covered="0"/>
</sourcefile> By looking that I guess jacoco still does not handle the scala source files correctly and reports invalid lines from source file Why |
Yea, when I dug a bit into the jacoco and cobertura inputs to this plugin, I did see that they appeared to both output things talking about B.scala:7, which they shouldn't have been, meaning it as least partly not this plugin's fault, most likely. The really strange thing is that that line number, or at least the line number reported in the error msg from this plugin, changes based on what line number in A.scala the |
Yea, that's a good finding. I also checked that out too and it seems that the case class line number in <sourcefile name="B.scala">
<line nr="3" mi="116" ci="0" mb="16" cb="0"/>
<line nr="4" mi="12" ci="0" mb="0" cb="0"/>
<counter type="INSTRUCTION" missed="139" covered="0"/>
<counter type="BRANCH" missed="16" covered="0"/>
<counter type="LINE" missed="2" covered="0"/>
<counter type="COMPLEXITY" missed="29" covered="0"/>
<counter type="METHOD" missed="21" covered="0"/>
<counter type="CLASS" missed="2" covered="0"/>
</sourcefile>
<sourcefile name="A.scala">
<line nr="4" mi="122" ci="0" mb="16" cb="0"/>
<counter type="INSTRUCTION" missed="133" covered="0"/>
<counter type="BRANCH" missed="16" covered="0"/>
<counter type="LINE" missed="1" covered="0"/>
<counter type="COMPLEXITY" missed="28" covered="0"/>
<counter type="METHOD" missed="20" covered="0"/>
<counter type="CLASS" missed="2" covered="0"/>
</sourcefile> I did not change Your correct way to use scoverage should be documented in the readme and I'll try to put that together at some point soon. Your help on this one has been great! |
Sounds great, thanks for following up and for making this! |
Hey guys, just a further comment I want to point that the scalac compiler is generating all this mess. Compile the code with Remember that JaCoCo works directly with the JVM bytecode and will map the bytecode instruction to lines in the sourcefile looking in the LineNumberTable. |
@andrioli fair enough. Let's not blame the tools just because they are used in a context they are not intended to work. |
I'm seeing this error, already discussed on #73 and #82, and have made as small a repro case as I can in this repo: https://github.com/ryan-williams/coverage-test. I'm using version
4.2.0
of this plugin and jacoco0.7.7.201606060606
.case class A
is declared on A.scala:7, and for some reason that line number (7) is being looked up in B.scala, which is only 6 lines long.Here you can see it having failed on Travis (the build succeeded, but if you look at the logs for after_success command you can see the
coveralls:report
failure.The text was updated successfully, but these errors were encountered: