Skip to content

sbt-scoverage compilation/typechecking issues #134

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

Closed
paddymahoney opened this issue Aug 27, 2015 · 6 comments
Closed

sbt-scoverage compilation/typechecking issues #134

paddymahoney opened this issue Aug 27, 2015 · 6 comments

Comments

@paddymahoney
Copy link

We add
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.1")
and then enable the ScoverageSbtPlugin plugin. With overageEnabled := true, we clean test.

sbt-scoverage produces a couple of coverage reports, but problems begin to occur:


[info] [info] Cleaning datadir [/Users/patrick/npl/core/target/scala-2.11/scoverage-data]
[info] [info] Beginning coverage instrumentation
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
...
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [info] Instrumentation completed [28579 statements]
[info] [info] Wrote instrumentation file [/Users/patrick/npl/core/target/scala-2.11/scoverage-data/scoverage.coverage.xml]
[info] [info] Will write measurement data to [/Users/patrick/npl/core/target/scala-2.11/scoverage-data]

Then, in the next project in our project dependencies:

[error] /Users/patrick/npl/runtime/src/main/scala/com/auvik/npl/table/TableActor.scala:199: type mismatch;
[error]  found   : _$5
[error]  required: _$4
[error]                   r + (col -> compiled.run(r))
[error]                                           ^
[error] /Users/patrick/npl/runtime/src/main/scala/com/auvik/npl/table/adapter/csv/CsvTable.scala:137: type mismatch;
[error]  found   : Any
[error]  required: _$58
[error]           (result._1 + (c -> compiled.run(result._1)), result._2)
[error]                                          ^
[error] /Users/patrick/npl/runtime/src/main/scala/com/auvik/npl/tools/Compiler.scala:250: type mismatch;
[error]  found   : com.auvik.npl.table.Table.scala.PKey
[error]     (which expands to)  Any
[error]  required: table.PKey
[error]         val debugRow = updated.getOrElse(Row(table.pKey -> aggregate.primaryKey(aggregateContext)))
[error]                                                                                ^
[error] /Users/patrick/npl/runtime/src/main/scala/com/auvik/npl/tools/RuntimeContext.scala:1255: type mismatch;
[error]  found   : com.auvik.npl.table.Table.scala.PKey
[error]     (which expands to)  Any
[error]  required: tableInfo.PKey
[error]       val debugRow = updated.getOrElse(Row(tableInfo.pKey -> aggregate.primaryKey(aggregateContext)))
[error]                                                                                  ^

This code typechecks without coverage. It seems like the code that fails involves type aliases including existential types.

Not sure if this belongs here or in scoverage itself.

@sksamuel
Copy link
Member

Probably in the scoverage project. do you have a small bit of code that's compilable that reproduces this that I can use in a unit test?

@alexflav23
Copy link

Hi @paddymahoney @sksamuel,

I believe this occurs because the coverage session is sticky, so when you publish an artefact immediately after running scoverage and generating reports, the published artefacts are somehow altered which leads to the current problem.

Try repeating the whole sequence and simply reload after you are doing with instrumentation or unstage the sticky coverage command with coverageOff command. If you are doing this directly in your build the problem may be more permanent. I have no specific idea why this happens as I'm unfamiliar with the internals of scoverage yet I've seen the problem before and this was the solution.

Hope this helps, if I'm on the money it should probably go in the docs as I think all published artefacts are affected if coverage is on at the time publish is ran.

@farmdawgnation
Copy link

Hi,

I'm trying to get scoverage enabled for lift/framework so that we can pull coverage information into Codacy and we're running into a similar issue. What's the status of this bug?

@sukumarinbox
Copy link

Hello All I am using

Jenkins
Jenkins ver. 1.625.18.3 (CloudBees Jenkins Enterprise 15.11)
scoverage plugin:
SbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
sbt version
sbt-0.13.9
sbt settings:
[process_args] java_version = '1.8.0_111'

Executing command line:

java
-Xms4096m
-Xmx4096m
-XX:ReservedCodeCacheSize=512m
-XX:MaxMetaspaceSize=1024m
-jar
when i issue sbt coverage test coverageReport from jenkins
I am getting the below issue
[info] [info] Beginning coverage instrumentation
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.
[info] [warn] Could not instrument [EmptyTree$/null]. No pos.

And the same if i try to do command line (linux) i am getting coverage

Could any one help me here. Thanks in advance

@gslowikowski
Copy link
Member

I think, I've fixed it in scoverage/scalac-scoverage-plugin#194, but it's not released yet.

You can build scalac-scoverage-plugin locally (sbt +publishLocal), add

coverageScalacPluginVersion = "1.3.1-SNAPSHOT"

to your build.sbt file and test it.

@ckipp01
Copy link
Member

ckipp01 commented May 7, 2021

Looking back at the above I believe this issue should be fixed so I'm going to go ahead and close. Feel free to open back up if the issue still persists.

@ckipp01 ckipp01 closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants