Skip to content

Allow for code coverage to be run on 0.27.1 #780

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

Merged
merged 4 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def _write_executable_non_windows(ctx, executable, rjars, main_class, jvm_flags,

if use_jacoco and _coverage_replacements_provider.is_enabled(ctx):
classpath = ctx.configuration.host_path_separator.join(
["${RUNPATH}%s" % (j.short_path) for j in rjars.to_list() + ctx.files._jacocorunner + ctx.files._lcov_merger],
["${RUNPATH}%s" % (j.short_path) for j in rjars.to_list() + ctx.files._jacocorunner],
)
jacoco_metadata_file = ctx.actions.declare_file(
"%s.jacoco_metadata.txt" % ctx.attr.name,
Expand Down
16 changes: 0 additions & 16 deletions scala/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,6 @@ def scala_repositories(
server_urls = maven_servers,
)

_scala_maven_import_external(
name = "io_bazel_rules_scala_org_jacoco_org_jacoco_core",
artifact = "org.jacoco:org.jacoco.core:0.7.5.201505241946",
jar_sha256 = "ecf1ad8192926438d0748bfcc3f09bebc7387d2a4184bb3a171a26084677e808",
licenses = ["notice"],
server_urls = maven_servers,
)

_scala_maven_import_external(
name = "io_bazel_rules_scala_org_ow2_asm_asm_debug_all",
artifact = "org.ow2.asm:asm-debug-all:5.0.1",
jar_sha256 = "4734de5b515a454b0096db6971fb068e5f70e6f10bbee2b3bd2fdfe5d978ed57",
licenses = ["notice"],
server_urls = maven_servers,
)

if not native.existing_rule("com_google_protobuf"):
http_archive(
name = "com_google_protobuf",
Expand Down
5 changes: 1 addition & 4 deletions src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ java_binary(
],
main_class = "io.bazel.rulesscala.coverage.instrumenter.JacocoInstrumenter",
visibility = ["//visibility:public"],
runtime_deps = [
"@io_bazel_rules_scala_org_ow2_asm_asm_debug_all",
],
deps = [
"@io_bazel_rules_scala//src/java/com/google/devtools/build/lib:worker",
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/jar",
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/worker",
"@io_bazel_rules_scala_org_jacoco_org_jacoco_core",
"@bazel_tools//tools/jdk:JacocoCoverage",
],
)

Expand Down
4 changes: 3 additions & 1 deletion test/coverage/A2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
object A2 {
def a2(): Unit = {
println("a2: " + B2.b2_a())
println("a2: " +
"" // B2.b2_a()
)
}
}
5 changes: 3 additions & 2 deletions test/coverage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ scala_library(
name = "a2",
srcs = [
"A2.scala",
],
],
deps = [
":b2",
# TODO :: Understand why referencing a local java library breaks coverage
# ":b2",
],
)

Expand Down
22 changes: 3 additions & 19 deletions test/coverage/expected-coverage.dat
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LF:3
end_of_record
SF:/A2.scala
FN:-1,A2$::<clinit> ()V
FN:5,A2$::<init> ()V
FN:7,A2$::<init> ()V
FN:3,A2$::a2 ()V
FN:-1,A2::a2 ()V
FNDA:1,A2$::<clinit> ()V
Expand All @@ -29,8 +29,8 @@ FNDA:1,A2$::a2 ()V
FNDA:0,A2::a2 ()V
FNF:4
FNH:3
DA:3,11
DA:5,5
DA:3,4
DA:7,5
LH:2
LF:2
end_of_record
Expand All @@ -50,22 +50,6 @@ DA:7,5
LH:1
LF:2
end_of_record
SF:/C2.scala
FN:-1,C2$::<clinit> ()V
FN:5,C2$::<init> ()V
FN:3,C2$::c2 (Ljava/lang/String;)Ljava/lang/String;
FN:-1,C2::c2 (Ljava/lang/String;)Ljava/lang/String;
FNDA:1,C2$::<clinit> ()V
FNDA:1,C2$::<init> ()V
FNDA:1,C2$::c2 (Ljava/lang/String;)Ljava/lang/String;
FNDA:1,C2::c2 (Ljava/lang/String;)Ljava/lang/String;
FNF:4
FNH:4
DA:3,9
DA:5,5
LH:2
LF:2
end_of_record
SF:/TestAll.scala
FN:10,TestAll$$anonfun$1::<init> (LTestAll;)V
FN:10,TestAll$$anonfun$1::apply ()V
Expand Down