-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
ATTENTION! Please read and follow:
- if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to [email protected]
- if this is a bug or feature request, fill the form below as best as you can.
Description of the problem / feature request:
When building Scala 2.12 with https://github.com/bazelbuild/rules_scala coverage has a bug (Scala lambdas are not properly detected). This has been tracked down to a bug in Jacoco 0.8.3 + Scala 2.12 (Jacoco did not properly recognize Scala 2.12 lambdas in 0.8.3).
Jacoco 0.8.5 contains a bugfix for this problem.
To fix this issue Jacoco would need to be upgraded from 0.8.3 to 0.8.5 in Bazel.
Feature requests: what underlying problem are you trying to solve with this feature?
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Reproduction with Bazel:
- Check out rules_scala repository on master branch.
- Generate coverage data:
bazel coverage --extra_toolchains="//scala:code_coverage_toolchain" //test/coverage/... - Generated coverage report:
genhtml -o ${destdir} --ignore-errors source bazel-out/k8-fastbuild/testlogs/test/coverage/test-all/coverage.dat - In coverage/D1.scala.gcov.html only the first line is shown as covered
Outside of Bazel:
Download http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.5/jacoco-0.8.5.zip and http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.3/jacoco-0.8.3.zip.
Take https://github.com/bazelbuild/rules_scala/blob/master/test/coverage/D1.scala and add a main method to it:
def main(args: Array[String]) {
D1.veryLongFunctionNameIsHereAaaaaaaaa()
}
Steps:
# Install Scala 2.12 into ~/opt/scala-2.12.10
# Unpack jacoco archive (in this case 0.8.5).
unzip ~/Downloads/jacoco-0.8.5.zip
mkdir classes
# Added a main method to test/coverage/D1.scala and moved it to src/ folder.
scalac src/D1.scala -d classes
java -javaagent:lib/jacocoagent.jar -cp ~/opt/scala-2.12.10/lib/scala-library.jar:classes D1
java -jar lib/jacococli.jar report jacoco.exec --classfiles classes --sourcefiles src --html report
# Check the Jacoco report (a bit different graphical interface than for LCOV).
firefox report/index.html
- When using Jacoco 0.8.3:
a) Missed instructions: 3 of 32
b) only the first line of veryLongFunctionNameIsHereAaaaaaaaa is covered. - When using Jacoco 0.8.5:
a) Missed instructions: 3 of 295
b) all lines of veryLongFunctionNameIsHereAaaaaaaaa are covered.
What operating system are you running Bazel on?
Ubuntu 18.04.
What's the output of bazel info release?
release 3.0.0
If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.
Replace this line with your answer.
What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?
https://github.com/bazelbuild/rules_scala
056d5921d2c595e7ce2d54a627e8bc68ece7e28d
056d5921d2c595e7ce2d54a627e8bc68ece7e28d
Have you found anything relevant by searching the web?
Rules scala bug report details:
bazel-contrib/rules_scala#1056
bazel-contrib/rules_scala#1054
Scala 2.12 changes for lambda bytecode:
https://users.scala-lang.org/t/has-a-loop-recurs-comprehension-been-considered-for-scala/4787/21
https://www.scala-lang.org/news/2.12.0/
Jacoco Java lambda support:
https://stackoverflow.com/questions/45674950/jacoco-need-special-handling-fro-lambdas
https://stackoverflow.com/questions/32284326/code-coverage-for-lambda-function
jacoco/jacoco#232
Jacoco Scala lambda fix:
jacoco/jacoco#912
jacoco/jacoco#922
Any other information, logs, or outputs that you want to share?
More detailed information may be found at:
bazel-contrib/rules_scala#1056
bazel-contrib/rules_scala#1054